this commit is broken

git-svn-id: https://svn.eduke32.com/eduke32@1468 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2009-07-27 05:33:12 +00:00
parent 633322506a
commit 68e35cb442
12 changed files with 728 additions and 195 deletions

View file

@ -0,0 +1,510 @@
//-------------------------------------------------------------------------
/*
Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Dummy AudioLib stub implementation by Jonathon Fowler (jonof@edgenetwk.com)
*/
//-------------------------------------------------------------------------
#include "music.h"
#define TRUE ( 1 == 1 )
#define FALSE ( !TRUE )
int32_t MUSIC_ErrorCode = MUSIC_Ok;
/*---------------------------------------------------------------------
Function: MUSIC_ErrorString
Returns a pointer to the error message associated with an error
number. A -1 returns a pointer the current error.
---------------------------------------------------------------------*/
char *MUSIC_ErrorString
(
int32_t ErrorNumber
)
{
char *ErrorString;
switch (ErrorNumber)
{
case MUSIC_Warning :
case MUSIC_Error :
ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode);
break;
case MUSIC_Ok :
ErrorString = "Music ok.";
break;
case MUSIC_ASSVersion :
ErrorString = "Apogee Sound System Version "
"Programmed by Jim Dose\n"
"(c) Copyright 1996 James R. Dose. All Rights Reserved.\n";
break;
case MUSIC_SoundCardError :
break;
case MUSIC_MPU401Error :
ErrorString = "Could not detect MPU-401.";
break;
case MUSIC_InvalidCard :
ErrorString = "Invalid Music device.";
break;
case MUSIC_MidiError :
ErrorString = "Error playing MIDI file.";
break;
case MUSIC_TaskManError :
ErrorString = "TaskMan error.";
break;
case MUSIC_DPMI_Error :
ErrorString = "DPMI Error in MUSIC.";
break;
default :
ErrorString = "Unknown Music error code.";
break;
}
return(ErrorString);
}
/*---------------------------------------------------------------------
Function: MUSIC_Init
Selects which sound device to use.
---------------------------------------------------------------------*/
int32_t MUSIC_Init
(
int32_t SoundCard,
int32_t Address
)
{
int32_t i;
int32_t status;
status = MUSIC_Ok;
return(status);
}
/*---------------------------------------------------------------------
Function: MUSIC_Shutdown
Terminates use of sound device.
---------------------------------------------------------------------*/
int32_t MUSIC_Shutdown
(
void
)
{
int32_t status;
status = MUSIC_Ok;
return(status);
}
/*---------------------------------------------------------------------
Function: MUSIC_SetMaxFMMidiChannel
Sets the maximum MIDI channel that FM cards respond to.
---------------------------------------------------------------------*/
void MUSIC_SetMaxFMMidiChannel
(
int32_t channel
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_SetVolume
Sets the volume of music playback.
---------------------------------------------------------------------*/
void MUSIC_SetVolume
(
int32_t volume
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_SetMidiChannelVolume
Sets the volume of music playback on the specified MIDI channel.
---------------------------------------------------------------------*/
void MUSIC_SetMidiChannelVolume
(
int32_t channel,
int32_t volume
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_ResetMidiChannelVolumes
Sets the volume of music playback on all MIDI channels to full volume.
---------------------------------------------------------------------*/
void MUSIC_ResetMidiChannelVolumes
(
void
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_GetVolume
Returns the volume of music playback.
---------------------------------------------------------------------*/
int32_t MUSIC_GetVolume
(
void
)
{
return(0);
}
/*---------------------------------------------------------------------
Function: MUSIC_SetLoopFlag
Set whether the music will loop or end when it reaches the end of
the song.
---------------------------------------------------------------------*/
void MUSIC_SetLoopFlag
(
int32_t loopflag
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_SongPlaying
Returns whether there is a song playing.
---------------------------------------------------------------------*/
int32_t MUSIC_SongPlaying
(
void
)
{
return(0);
}
/*---------------------------------------------------------------------
Function: MUSIC_Continue
Continues playback of a paused song.
---------------------------------------------------------------------*/
void MUSIC_Continue
(
void
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_Pause
Pauses playback of a song.
---------------------------------------------------------------------*/
void MUSIC_Pause
(
void
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_StopSong
Stops playback of current song.
---------------------------------------------------------------------*/
int32_t MUSIC_StopSong
(
void
)
{
return(MUSIC_Ok);
}
/*---------------------------------------------------------------------
Function: MUSIC_PlaySong
Begins playback of MIDI song.
---------------------------------------------------------------------*/
int32_t MUSIC_PlaySong
(
uint8_t *song,
int32_t loopflag
)
{
return(MUSIC_Ok);
}
/*---------------------------------------------------------------------
Function: MUSIC_SetContext
Sets the song context.
---------------------------------------------------------------------*/
void MUSIC_SetContext
(
int32_t context
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_GetContext
Returns the current song context.
---------------------------------------------------------------------*/
int32_t MUSIC_GetContext
(
void
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_SetSongTick
Sets the position of the song pointer.
---------------------------------------------------------------------*/
void MUSIC_SetSongTick
(
uint32_t PositionInTicks
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_SetSongTime
Sets the position of the song pointer.
---------------------------------------------------------------------*/
void MUSIC_SetSongTime
(
uint32_t milliseconds
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_SetSongPosition
Sets the position of the song pointer.
---------------------------------------------------------------------*/
void MUSIC_SetSongPosition
(
int32_t measure,
int32_t beat,
int32_t tick
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_GetSongPosition
Returns the position of the song pointer.
---------------------------------------------------------------------*/
void MUSIC_GetSongPosition
(
songposition *pos
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_GetSongLength
Returns the length of the song.
---------------------------------------------------------------------*/
void MUSIC_GetSongLength
(
songposition *pos
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_FadeVolume
Fades music volume from current level to another over a specified
period of time.
---------------------------------------------------------------------*/
int32_t MUSIC_FadeVolume
(
int32_t tovolume,
int32_t milliseconds
)
{
return(MUSIC_Ok);
}
/*---------------------------------------------------------------------
Function: MUSIC_FadeActive
Returns whether the fade routine is active.
---------------------------------------------------------------------*/
int32_t MUSIC_FadeActive
(
void
)
{
return(0);
}
/*---------------------------------------------------------------------
Function: MUSIC_StopFade
Stops fading the music.
---------------------------------------------------------------------*/
void MUSIC_StopFade
(
void
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_RerouteMidiChannel
Sets callback function to reroute MIDI commands from specified
function.
---------------------------------------------------------------------*/
void MUSIC_RerouteMidiChannel
(
int32_t channel,
int32_t (*function)(int32_t event, int32_t c1, int32_t c2)
)
{
}
/*---------------------------------------------------------------------
Function: MUSIC_RegisterTimbreBank
Halts playback of all sounds.
---------------------------------------------------------------------*/
void MUSIC_RegisterTimbreBank
(
uint8_t *timbres
)
{
}
void MUSIC_Update(void)
{
}

View file

@ -301,7 +301,6 @@ extern int32_t probey;
extern char typebuflen;
extern char typebuf[141];
extern char *MusicPtr;
extern int32_t g_musicSize;
extern int32_t msx[2048],msy[2048];
extern int16_t cyclers[MAXCYCLERS][6],g_numCyclers;

View file

@ -30,8 +30,11 @@ extern void S_SoundStartup(void);
extern void S_SoundShutdown(void);
extern void S_MusicStartup(void);
extern void S_MusicShutdown(void);
extern void S_MusicVolume(int32_t);
extern void S_MenuSound(void);
extern int32_t S_PlayMusic(const char *fn, const int32_t sel);
extern void S_StopMusic(void);
extern void S_PauseMusic(int32_t);
extern int32_t S_LoadSound(unsigned num);
extern int32_t S_PlaySoundXYZ(int32_t num,int32_t i,const vec3_t *pos);
extern int32_t S_PlaySound(int32_t num);

View file

@ -579,7 +579,6 @@ void Net_GetPackets(void)
input_t *osyn, *nsyn;
sampletimer();
AudioUpdate();
G_HandleSpecialKeys();
@ -902,10 +901,7 @@ void Net_GetPackets(void)
if (ud.config.SoundToggle == 0 || ud.lockout == 1 || ud.config.FXDevice < 0 || !(ud.config.VoiceToggle & 4))
break;
rtsptr = (char *)RTS_GetSound(packbuf[1]-1);
if (*rtsptr == 'C')
FX_PlayVOC3D(rtsptr,0,0,0,255,-packbuf[1]);
else
FX_PlayWAV3D(rtsptr,0,0,0,255,-packbuf[1]);
FX_PlayAuto3D(rtsptr,RTS_SoundLength(packbuf[1]-1),0,0,0,255,-packbuf[1]);
g_RTSPlaying = 7;
break;
@ -1076,7 +1072,7 @@ void faketimerhandler(void)
}
sampletimer();
AudioUpdate();
if ((totalclock < ototalclock+TICSPERFRAME) || (ready2send == 0)) return;
ototalclock += TICSPERFRAME;
@ -2703,7 +2699,7 @@ static void G_DisplayExtraScreens(void)
{
int32_t flags = Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1);
MUSIC_StopSong();
S_StopMusic();
FX_StopAllSounds();
if (!VOLUMEALL || flags & LOGO_SHAREWARESCREENS)
@ -8455,9 +8451,7 @@ static void G_HandleLocalKeys(void)
if (ud.config.SoundToggle && ALT_IS_PRESSED && (RTS_NumSounds() > 0) && g_RTSPlaying == 0 && (ud.config.VoiceToggle & 1))
{
rtsptr = (char *)RTS_GetSound(i-1);
if (*rtsptr == 'C')
FX_PlayVOC3D(rtsptr,0,0,0,255,-i);
else FX_PlayWAV3D(rtsptr,0,0,0,255,-i);
FX_PlayAuto3D(rtsptr,RTS_SoundLength(i-1),0,0,0,255,-i);
g_RTSPlaying = 7;
@ -10011,7 +10005,7 @@ static void G_DisplayLogo(void)
Bsprintf(tempbuf,"%s - " APPNAME,duke3dgrpstring);
wm_setapptitle(tempbuf);
MUSIC_StopSong();
S_StopMusic();
FX_StopAllSounds(); // JBF 20031228
S_ClearSoundLocks(); // JBF 20031228
if (ud.multimode < 2 && (logoflags & LOGO_ENABLED) && !g_noLogo)
@ -11531,8 +11525,6 @@ MAIN_LOOP_RESTART:
quitevent = 0;
}
AudioUpdate();
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
bindsenabled = (g_player[myconnectindex].ps->gm == MODE_GAME || g_player[myconnectindex].ps->gm == MODE_DEMO);
@ -12971,12 +12963,12 @@ void G_BonusScreen(int32_t bonusonly)
Net_GetPackets();
}
fadepal(0,0,0, 0,64,1);
MUSIC_StopSong();
S_StopMusic();
FX_StopAllSounds();
S_ClearSoundLocks();
break;
case 1:
MUSIC_StopSong();
S_StopMusic();
clearview(0L);
nextpage();
@ -13011,7 +13003,7 @@ void G_BonusScreen(int32_t bonusonly)
setview(0,0,xdim-1,ydim-1);
MUSIC_StopSong();
S_StopMusic();
clearview(0L);
nextpage();
@ -13080,7 +13072,7 @@ void G_BonusScreen(int32_t bonusonly)
case 2:
MUSIC_StopSong();
S_StopMusic();
clearview(0L);
nextpage();
if (ud.lockout == 0)
@ -13172,7 +13164,7 @@ FRAGBONUS:
tinc = 0;
bonuscnt = 0;
MUSIC_StopSong();
S_StopMusic();
FX_StopAllSounds();
S_ClearSoundLocks();
@ -13333,7 +13325,6 @@ FRAGBONUS:
Net_GetPackets();
handleevents();
AudioUpdate();
if (g_player[myconnectindex].ps->gm&MODE_EOL)
{

View file

@ -1405,7 +1405,7 @@ static int32_t C_CheckEventSync(int32_t iEventID)
static inline int32_t ispecial(const char c)
{
if (c == ' ' || c == 0x0d || c == '(' || c == ')' ||
c == ',' || c == ';' || (c == 0x0a && ++g_lineNumber))
c == ',' || c == ';' || (c == 0x0a && ++g_lineNumber))
return 1;
return 0;

View file

@ -4533,7 +4533,7 @@ cheat_for_port_credits:
ud.config.MusicToggle = 1-ud.config.MusicToggle;
if (i != ud.config.MusicToggle)
{
if (ud.config.MusicToggle == 0) MUSIC_Pause();
if (ud.config.MusicToggle == 0) S_PauseMusic(1);
else
{
if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME)
@ -4543,7 +4543,7 @@ cheat_for_port_credits:
}
else S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS);
MUSIC_Continue();
S_PauseMusic(0);
}
}
}
@ -4557,7 +4557,7 @@ cheat_for_port_credits:
_bar(1,d+8,yy+7, &ud.config.MusicVolume,4,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,64);
ud.config.MusicVolume <<= 2;
if (l != ud.config.MusicVolume)
MUSIC_SetVolume((int16_t) ud.config.MusicVolume);
S_MusicVolume((int16_t) ud.config.MusicVolume);
}
break;
case 4:

View file

@ -4513,7 +4513,7 @@ void P_ProcessInput(int32_t snum)
// not jumping or crouching
if (!TEST_SYNC_KEY(sb_snum, SK_JUMP) && !TEST_SYNC_KEY(sb_snum, SK_CROUCH) &&
p->on_ground && (sector[psect].floorstat&2) && p->posz >= (fz-(i<<8)-(16<<8)))
p->on_ground && (sector[psect].floorstat&2) && p->posz >= (fz-(i<<8)-(16<<8)))
p->posz = fz-(i<<8);
else
{

View file

@ -426,10 +426,10 @@ void G_CacheMapData(void)
if (ud.recstat == 2)
return;
MUSIC_Pause();
S_PauseMusic(1);
if (MapInfo[MAXVOLUMES*MAXLEVELS+2].musicfn1)
{
MUSIC_StopSong();
S_StopMusic();
S_PlayMusic(&EnvMusicFilename[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus
}

View file

@ -490,10 +490,10 @@ int32_t G_LoadPlayer(int32_t spot)
if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL && (i != g_musicIndex || MapInfo[MAXVOLUMES*MAXLEVELS+2].musicfn1))
{
MUSIC_StopSong();
S_StopMusic();
S_PlayMusic(&MapInfo[(uint8_t)g_musicIndex].musicfn[0],g_musicIndex);
}
MUSIC_Continue();
S_PauseMusic(0);
g_player[myconnectindex].ps->gm = MODE_GAME;
ud.recstat = 0;

View file

@ -2517,13 +2517,13 @@ void G_HandleSharedKeys(int32_t snum)
else ud.pause_on = 1+SHIFTS_IS_PRESSED;
if (ud.pause_on)
{
MUSIC_Pause();
S_PauseMusic(1);
FX_StopAllSounds();
S_ClearSoundLocks();
}
else
{
if (ud.config.MusicToggle) MUSIC_Continue();
if (ud.config.MusicToggle) S_PauseMusic(0);
pub = NUMPAGES;
pus = NUMPAGES;
}

View file

@ -32,16 +32,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "util_lib.h"
#include "osd.h"
#ifdef _WIN32
#ifdef USE_OPENAL
#include "openal.h"
#endif
#endif
#define LOUDESTVOLUME 150
int32_t backflag,g_numEnvSoundsPlaying,g_maxSoundPos = 0;
#define MUSIC_ID -65536
static int32_t MusicIsWaveform = 0;
static uint8_t * MusicPtr = 0;
static int32_t MusicLen = 0;
static int32_t MusicVoice = -1;
static int32_t MusicPaused = 0;
/*
===================
=
@ -52,44 +54,43 @@ int32_t backflag,g_numEnvSoundsPlaying,g_maxSoundPos = 0;
void S_SoundStartup(void)
{
int32_t status, err = 0;
int32_t status;
int32_t fxdevicetype;
void * initdata = 0;
// if they chose None lets return
if (ud.config.FXDevice < 0) return;
if (ud.config.FXDevice < 0)
{
return;
}
else if (ud.config.FXDevice == 0)
{
fxdevicetype = ASS_AutoDetect;
}
else
{
fxdevicetype = ud.config.FXDevice - 1;
}
initprintf("Initializing sound...\n");
#ifdef WIN32
initdata = (void *) win_gethwnd();
#endif
RETRY:
status = FX_Init(ud.config.FXDevice, ud.config.NumVoices, ud.config.NumChannels, ud.config.NumBits, ud.config.MixRate);
status = FX_Init(fxdevicetype, ud.config.NumVoices, ud.config.NumChannels, ud.config.NumBits, ud.config.MixRate, initdata);
if (status == FX_Ok)
{
FX_SetVolume(ud.config.FXVolume);
if (ud.config.ReverseStereo == 1)
{
FX_SetReverseStereo(!FX_GetReverseStereo());
}
FX_SetReverseStereo(ud.config.ReverseStereo);
status = FX_SetCallBack(S_TestSoundCallback);
}
if (status != FX_Ok)
{
if (!err)
{
#if defined(_WIN32)
ud.config.MixRate = 44100;
#else
ud.config.MixRate = 48000;
#endif
ud.config.NumBits = 16;
ud.config.NumChannels = 2;
ud.config.NumVoices = 32;
ud.config.ReverseStereo = 0;
err = 1;
goto RETRY;
}
Bsprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error));
sprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error));
G_GameExit(tempbuf);
}
ud.config.FXDevice = 0;
}
/*
@ -108,6 +109,11 @@ void S_SoundShutdown(void)
if (ud.config.FXDevice < 0)
return;
if (MusicVoice >= 0)
{
S_MusicShutdown();
}
status = FX_Shutdown();
if (status != FX_Ok)
{
@ -182,6 +188,8 @@ void S_MusicShutdown(void)
if (ud.config.MusicDevice < 0)
return;
S_StopMusic();
status = MUSIC_Shutdown();
if (status != MUSIC_Ok)
{
@ -189,6 +197,34 @@ void S_MusicShutdown(void)
}
}
void S_PauseMusic(int32_t onf)
{
if (MusicPaused == onf || (MusicIsWaveform && MusicVoice < 0))
return;
if (MusicIsWaveform)
FX_PauseVoice(MusicVoice, onf);
else if (onf)
MUSIC_Pause();
else
MUSIC_Continue();
MusicPaused = onf;
}
void S_MusicVolume(int32_t volume)
{
if (MusicIsWaveform && MusicVoice >= 0)
{
FX_SetPan(MusicVoice, volume, volume, volume);
}
else if (!MusicIsWaveform)
{
MUSIC_SetVolume(volume);
}
}
void S_MenuSound(void)
{
static int32_t SoundNum=0;
@ -216,6 +252,7 @@ void S_MenuSound(void)
SoundNum %= (sizeof(menusnds)/sizeof(menusnds[0]));
}
/*
void _playmusic(const char *fn)
{
int32_t fp, l, i;
@ -265,6 +302,86 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
}
return 1;
}
*/
int32_t S_PlayMusic(const char *fn, const int32_t sel)
{
int32_t fp;
char * testfn, * extension;
if (ud.config.MusicToggle == 0) return 0;
if (ud.config.MusicDevice < 0) return 0;
testfn = (char *) malloc(strlen(fn) + 5);
strcpy(testfn, fn);
extension = strrchr(testfn, '.');
do
{
if (extension && !Bstrcasecmp(extension, ".mid"))
{
// we've been asked to load a .mid file, but first
// let's see if there's an ogg with the same base name
// lying around
strcpy(extension, ".ogg");
fp = kopen4load(testfn, 0);
if (fp >= 0)
{
free(testfn);
break;
}
}
free(testfn);
// just use what we've been given
fp = kopen4load((char *)fn, 0);
}
while (0);
if (fp < 0) return 0;
S_StopMusic();
MusicLen = kfilelength(fp);
MusicPtr = (uint8_t *) Bmalloc(MusicLen);
kread(fp, MusicPtr, MusicLen);
kclose(fp);
if (!memcmp(MusicPtr, "MThd", 4))
{
MUSIC_PlaySong(MusicPtr, MUSIC_LoopSong);
MusicIsWaveform = 0;
}
else
{
MusicVoice = FX_PlayLoopedAuto(MusicPtr, MusicLen, 0, 0, 0,
ud.config.MusicVolume, ud.config.MusicVolume, ud.config.MusicVolume,
FX_MUSIC_PRIORITY, MUSIC_ID);
MusicIsWaveform = 1;
}
return 0;
}
void S_StopMusic(void)
{
if (MusicIsWaveform && MusicVoice >= 0)
{
FX_StopSound(MusicVoice);
MusicVoice = -1;
}
else if (!MusicIsWaveform)
{
MUSIC_StopSong();
}
if (MusicPtr)
{
Bfree(MusicPtr);
MusicPtr = 0;
MusicLen = 0;
}
}
int32_t S_LoadSound(uint32_t num)
{
@ -366,7 +483,7 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos)
pitche = g_sounds[num].pe;
j = klabs(pitche-pitchs);
if (j)
{
if (pitchs < pitche)
@ -388,10 +505,10 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos)
default:
if (g_player[screenpeek].ps->cursectnum > -1 && sector[g_player[screenpeek].ps->cursectnum].lotag == 2 && (g_sounds[num].m&4) == 0)
pitch = -768;
/*
if (sndist > 31444 && PN != MUSICANDSFX)
return -1;
*/
/*
if (sndist > 31444 && PN != MUSICANDSFX)
return -1;
*/
break;
}
@ -433,30 +550,14 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos)
if (g_sounds[num].m&1)
{
uint16_t start;
if (g_sounds[num].num > 0) return -1;
start = *(uint16_t *)(g_sounds[num].ptr + 0x14);
if (*g_sounds[num].ptr == 'C')
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num);
else if (*g_sounds[num].ptr == 'O')
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num);
else
voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num);
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
}
else
{
if (*g_sounds[num].ptr == 'C')
voice = FX_PlayVOC3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
else if (*g_sounds[num].ptr == 'O')
voice = FX_PlayOGG3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
else
voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
}
if (voice >= FX_Ok)
@ -473,7 +574,6 @@ int32_t S_PlaySound(int32_t num)
{
int32_t pitch,pitche,pitchs,cx;
int32_t voice;
int32_t start;
if (ud.config.FXDevice < 0) return -1;
if (ud.config.SoundToggle==0) return -1;
@ -511,33 +611,12 @@ int32_t S_PlaySound(int32_t num)
if (g_sounds[num].m&1)
{
if (*g_sounds[num].ptr == 'C')
{
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
}
else if (*g_sounds[num].ptr == 'O')
{
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
}
else
{
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
}
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].soundsiz,num);
}
else
{
if (*g_sounds[num].ptr == 'C')
voice = FX_PlayVOC3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
else if (*g_sounds[num].ptr == 'O')
voice = FX_PlayOGG3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
else
voice = FX_PlayWAV3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
}
if (voice >= FX_Ok) return voice;
@ -611,7 +690,7 @@ void S_Pan3D(void)
j = g_maxSoundPos;
do
do
{
for (k=g_sounds[j].num-1; k>=0; k--)
{
@ -667,19 +746,25 @@ void S_Pan3D(void)
FX_Pan3D(g_sounds[j].SoundOwner[k].voice,sndang>>4,sndist>>6);
}
} while (j--);
}
while (j--);
}
void S_TestSoundCallback(uint32_t num)
{
int32_t tempi,tempj,tempk;
if ((int32_t)num < 0)
{
if (lumplockbyte[num] >= 200)
lumplockbyte[num]--;
return;
}
if ((int32_t) num == MUSIC_ID)
{
return;
}
if((int32_t)num < 0)
{
if(lumplockbyte[-num] >= 200)
lumplockbyte[-num]--;
return;
}
tempk = g_sounds[num].num;
@ -701,8 +786,8 @@ void S_TestSoundCallback(uint32_t num)
}
}
g_sounds[num].num--;
g_sounds[num].SoundOwner[tempk-1].i = -1;
g_sounds[num].num--;
g_sounds[num].SoundOwner[tempk-1].i = -1;
}
g_soundlocks[num]--;

View file

@ -28,24 +28,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h>
#include <string.h>
#include "compat.h"
#include "fx_man.h"
//#include "music.h"
//#include "duke3d.h"
//#include "util_lib.h"
#include "util_lib.h"
#include "osd.h"
//#include "compat.h"
#include "cache1d.h"
#include "macros.h"
#include "mathutil.h"
#include "build.h" // vec3_t
#ifdef _WIN32
#ifdef USE_OPENAL
#include "openal.h"
#endif
#endif
#include "sounds_mapster32.h"
#define LOUDESTVOLUME 150
@ -75,9 +70,12 @@ extern void initprintf(const char *f, ...);
===================
*/
int32_t S_SoundStartup(void)
{
int32_t status, err = 0;
int32_t status;
int32_t fxdevicetype;
void * initdata = 0;
// TODO: read config
int32_t FXVolume=220, /*NumVoices=32,*/ NumChannels=2, NumBits=16, MixRate, ReverseStereo=0;
@ -86,43 +84,28 @@ int32_t S_SoundStartup(void)
#else
MixRate = 48000;
#endif
fxdevicetype = ASS_AutoDetect;
// if they chose None lets return
if (0) return -1; // TODO: read config
#ifdef WIN32
initdata = (void *) win_gethwnd();
#endif
RETRY:
status = FX_Init(0, NumVoices, NumChannels, NumBits, MixRate);
status = FX_Init(fxdevicetype, NumVoices, NumChannels, NumBits, MixRate, initdata);
if (status == FX_Ok)
{
FX_SetVolume(FXVolume);
if (ReverseStereo == 1)
{
FX_SetReverseStereo(!FX_GetReverseStereo());
}
FX_SetReverseStereo(ReverseStereo);
status = FX_SetCallBack(S_TestSoundCallback);
}
if (status != FX_Ok)
{
if (!err)
{
#if defined(_WIN32)
MixRate = 44100;
#else
MixRate = 48000;
#endif
NumBits = 16;
NumChannels = 2;
NumVoices = 32;
ReverseStereo = 0;
err = 1;
goto RETRY;
}
initprintf("Sound startup error: %s", FX_ErrorString(FX_Error));
return -2;
}
SM32_havesound = 1;
return 0;
}
@ -286,30 +269,14 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos)
if (g_sounds[num].m&1)
{
uint16_t start;
if (g_sounds[num].num > 0) return -1;
start = *(uint16_t *)(g_sounds[num].ptr + 0x14);
if (*g_sounds[num].ptr == 'C')
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num);
else if (*g_sounds[num].ptr == 'O')
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num);
else
voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num);
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
}
else
{
if (*g_sounds[num].ptr == 'C')
voice = FX_PlayVOC3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
else if (*g_sounds[num].ptr == 'O')
voice = FX_PlayOGG3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
else
voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
}
if (voice >= FX_Ok)
@ -326,7 +293,6 @@ void S_PlaySound(int32_t num)
{
int32_t pitch,pitche,pitchs,cx;
int32_t voice;
int32_t start;
if (!SM32_havesound) return;
if (SoundToggle==0) return;
@ -363,33 +329,12 @@ void S_PlaySound(int32_t num)
if (g_sounds[num].m&1)
{
if (*g_sounds[num].ptr == 'C')
{
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
}
else if (*g_sounds[num].ptr == 'O')
{
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
}
else
{
start = (int32_t)*(uint16_t *)(g_sounds[num].ptr + 0x14);
voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
}
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].soundsiz,num);
}
else
{
if (*g_sounds[num].ptr == 'C')
voice = FX_PlayVOC3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
else if (*g_sounds[num].ptr == 'O')
voice = FX_PlayOGG3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
else
voice = FX_PlayWAV3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
}
if (voice >= FX_Ok)// return;