Commit 2f85d531 authored by Steven Fuller's avatar Steven Fuller

Hackish support for OpenAL positional sound

parent 2757f756
...@@ -4,7 +4,7 @@ CC = gcc ...@@ -4,7 +4,7 @@ CC = gcc
#CFLAGS = -g -Wall #CFLAGS = -g -Wall
#CFLAGS = -g #CFLAGS = -g
#CFLAGS = -Os #CFLAGS = -Os
CFLAGS = -g -Wall -I/usr/local/openal/include CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_agent.o wl_game.o \ wl_act1.o wl_act2.o wl_agent.o wl_game.o \
...@@ -16,7 +16,7 @@ XOBJS = $(OBJS) $(ROBJS) vi_xlib.o ...@@ -16,7 +16,7 @@ XOBJS = $(OBJS) $(ROBJS) vi_xlib.o
GOBJS = $(OBJS) vi_ogl.o vi_glx.o GOBJS = $(OBJS) vi_ogl.o vi_glx.o
#LFLAGS = -lm #LFLAGS = -lm
LFLAGS = -lm -L/usr/local/openal/lib -lopenal -lpthread -ldl LFLAGS = -lm -L/home/relnev/cvs/oal/linux/src -lopenal -lpthread -ldl
SLFLAGS = $(LFLAGS) -lvga SLFLAGS = $(LFLAGS) -lvga
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext
......
...@@ -56,17 +56,17 @@ typedef enum {false,true} boolean; ...@@ -56,17 +56,17 @@ typedef enum {false,true} boolean;
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned short int word; typedef unsigned short int word;
typedef unsigned long longword; typedef unsigned long longword;
typedef long fixed;
typedef void * memptr; typedef void * memptr;
typedef struct typedef struct {
{ int x, y;
int x,y; } Point;
} Point;
typedef struct typedef struct {
{ Point ul, lr;
Point ul,lr; } Rect;
} Rect;
#include "vi_comm.h" #include "vi_comm.h"
#include "sd_comm.h" #include "sd_comm.h"
...@@ -75,14 +75,15 @@ typedef struct ...@@ -75,14 +75,15 @@ typedef struct
#include "id_vh.h" #include "id_vh.h"
#include "id_us.h" #include "id_us.h"
extern byte signon[]; extern byte introscn[];
#define introscn signon
int MS_CheckParm(char *string); int MS_CheckParm(char *string);
int WolfMain(int argc, char *argv[]); int WolfMain(int argc, char *argv[]);
void Quit(char *error); void Quit(char *error);
#undef PI
#define PI 3.141592657
#define MAXTICS 10 #define MAXTICS 10
#define DEMOTICS 4 #define DEMOTICS 4
......
...@@ -71,7 +71,7 @@ unsigned char gamepal[] = ...@@ -71,7 +71,7 @@ unsigned char gamepal[] =
}; };
unsigned long int gamepal_size = 768; unsigned long int gamepal_size = 768;
unsigned char signon[] = unsigned char introscn[] =
{ 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, { 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
...@@ -5882,4 +5882,4 @@ unsigned char signon[] = ...@@ -5882,4 +5882,4 @@ unsigned char signon[] =
0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,'\0' 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,'\0'
}; };
unsigned long int signon_size = 64000; unsigned long int introscn_size = 64000;
...@@ -25,15 +25,6 @@ typedef struct ...@@ -25,15 +25,6 @@ typedef struct
byte data[1]; byte data[1];
} PCSound; } PCSound;
typedef struct
{
SoundCommon common;
word hertz;
byte bits,
reference,
data[1];
} SampledSound;
typedef struct typedef struct
{ {
byte mChar,cChar, byte mChar,cChar,
...@@ -113,31 +104,27 @@ extern boolean DigiPlaying; ...@@ -113,31 +104,27 @@ extern boolean DigiPlaying;
extern int DigiMap[]; extern int DigiMap[];
// Function prototypes // Function prototypes
extern void SD_Startup(void), extern void SD_Startup(void), SD_Shutdown(void);
SD_Shutdown(void),
SD_Default(boolean gotit,SDMode sd,SMMode sm),
SD_PositionSound(int leftvol,int rightvol);
extern boolean SD_PlaySound(soundnames sound);
extern void SD_SetPosition(int leftvol,int rightvol),
SD_StopSound(void),
SD_WaitSoundDone(void),
extern void SD_PlaySound(soundnames sound);
extern void SD_StopSound(void),
SD_WaitSoundDone(void),
SD_StartMusic(MusicGroup *music), SD_StartMusic(MusicGroup *music),
SD_MusicOn(void), SD_MusicOn(void),
SD_MusicOff(void), SD_MusicOff(void),
SD_FadeOutMusic(void), SD_FadeOutMusic(void);
SD_SetUserHook(void (*hook)(void));
extern boolean SD_MusicPlaying(void), extern boolean SD_MusicPlaying(void),
SD_SetSoundMode(SDMode mode), SD_SetSoundMode(SDMode mode),
SD_SetMusicMode(SMMode mode); SD_SetMusicMode(SMMode mode);
extern word SD_SoundPlaying(void); extern word SD_SoundPlaying(void);
extern void SD_SetDigiDevice(SDSMode), extern void SD_SetDigiDevice(SDSMode),
SD_StopDigitized(void),
SD_Poll(void); SD_Poll(void);
void PlaySoundLocGlobal(word s, fixed gx, fixed gy);
void UpdateSoundLoc(fixed x, fixed y, int angle);
#else #else
#error "fix me TODO" #error "fix me TODO"
#endif #endif
...@@ -263,3 +263,123 @@ boolean SD_MusicPlaying(void) ...@@ -263,3 +263,123 @@ boolean SD_MusicPlaying(void)
{ {
return false; return false;
} }
//===========================================================================
/*
==========================
=
= SetSoundLoc - Given the location of an object (in terms of global
= coordinates, held in globalsoundx and globalsoundy), munges the values
= for an approximate distance from the left and right ear, and puts
= those values into leftchannel and rightchannel.
=
= JAB
=
==========================
*/
fixed globalsoundx,globalsoundy;
int leftchannel,rightchannel;
#define ATABLEMAX 15
byte righttable[ATABLEMAX][ATABLEMAX * 2] = {
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 0, 0, 0, 0, 0, 1, 3, 5, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 4, 0, 0, 0, 0, 0, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 4, 1, 0, 0, 0, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 5, 4, 2, 1, 0, 1, 2, 3, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 5, 4, 3, 2, 2, 3, 3, 5, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 4, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 5, 5, 6, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8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//
// calculate newx
//
xt = FixedByFrac(gx,viewcos);
yt = FixedByFrac(gy,viewsin);
x = (xt - yt) >> TILESHIFT;
//
// calculate newy
//
xt = FixedByFrac(gx,viewsin);
yt = FixedByFrac(gy,viewcos);
y = (yt + xt) >> TILESHIFT;
if (y >= ATABLEMAX)
y = ATABLEMAX - 1;
else if (y <= -ATABLEMAX)
y = -ATABLEMAX;
if (x < 0)
x = -x;
if (x >= ATABLEMAX)
x = ATABLEMAX - 1;
leftchannel = lefttable[x][y + ATABLEMAX];
rightchannel = righttable[x][y + ATABLEMAX];
}
/*
==========================
=
= SetSoundLocGlobal - Sets up globalsoundx & globalsoundy and then calls
= UpdateSoundLoc() to transform that into relative channel volumes. Those
= values are then passed to the Sound Manager so that they'll be used for
= the next sound played (if possible).
=
==========================
*/
void PlaySoundLocGlobal(word s,fixed gx,fixed gy)
{
SetSoundLoc(gx,gy);
SD_PositionSound(leftchannel,rightchannel);
if (SD_PlaySound(s))
{
globalsoundx = gx;
globalsoundy = gy;
}
}
void UpdateSoundLoc()
{
if (SoundPositioned)
{
SetSoundLoc(globalsoundx,globalsoundy);
SD_SetPosition(leftchannel,rightchannel);
}
}
...@@ -39,7 +39,6 @@ static boolean sbNoCheck,sbNoProCheck; ...@@ -39,7 +39,6 @@ static boolean sbNoCheck,sbNoProCheck;
static byte sbOldIntMask = -1; static byte sbOldIntMask = -1;
static byte *sbNextSegPtr; static byte *sbNextSegPtr;
static longword sbNextSegLen; static longword sbNextSegLen;
static SampledSound *sbSamples;
// SoundSource variables // SoundSource variables
boolean ssNoCheck; boolean ssNoCheck;
...@@ -74,25 +73,14 @@ ALuint *sources; ...@@ -74,25 +73,14 @@ ALuint *sources;
ALuint *buffers; ALuint *buffers;
void *cc; void *cc;
void SD_StopDigitized(void)
{
}
void SD_Poll(void) void SD_Poll(void)
{ {
} }
void SD_SetPosition(int leftpos,int rightpos)
{
}
void SD_SetDigiDevice(SDSMode mode) void SD_SetDigiDevice(SDSMode mode)
{ {
} }
// Public routines
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// //
// SD_SetSoundMode() - Sets which sound hardware to use for sound effects // SD_SetSoundMode() - Sets which sound hardware to use for sound effects
...@@ -186,7 +174,9 @@ void SD_Startup(void) ...@@ -186,7 +174,9 @@ void SD_Startup(void)
memcpy(dat+z, PM_GetPage(w + PMSoundStart), page->length); memcpy(dat+z, PM_GetPage(w + PMSoundStart), page->length);
z += page->length; z += page->length;
} }
alBufferData(buffers[x], AL_FORMAT_MONO8, dat, y, 6896); /* TODO: openal bug! */
//alBufferData(buffers[x], AL_FORMAT_MONO8, dat, y, 6896);
alBufferData(buffers[x], AL_FORMAT_MONO8, dat, y, 22050/4);
if(alGetError() != AL_NO_ERROR) { if(alGetError() != AL_NO_ERROR) {
printf("AL error\n"); printf("AL error\n");
...@@ -196,8 +186,8 @@ void SD_Startup(void) ...@@ -196,8 +186,8 @@ void SD_Startup(void)
x++; x++;
} }
sources = (ALuint *)malloc(sizeof(ALuint) * 1); sources = (ALuint *)malloc(sizeof(ALuint) * 4);
alGenSources(1, sources); alGenSources(4, sources);
} }
SD_Started = true; SD_Started = true;
...@@ -225,47 +215,76 @@ void SD_Shutdown(void) ...@@ -225,47 +215,76 @@ void SD_Shutdown(void)
SD_Started = false; SD_Started = false;
} }
///////////////////////////////////////////////////////////////////////////
//
// SD_PositionSound() - Sets up a stereo imaging location for the next
// sound to be played. Each channel ranges from 0 to 15.
//
///////////////////////////////////////////////////////////////////////////
void SD_PositionSound(int leftvol,int rightvol)
{
LeftPosition = leftvol;
RightPosition = rightvol;
nextsoundpos = true;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// //
// SD_PlaySound() - plays the specified sound on the appropriate hardware // SD_PlaySound() - plays the specified sound on the appropriate hardware
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
boolean SD_PlaySound(soundnames sound)
ALfloat gval[6], pval[6];
void SD_PlaySound(soundnames sound)
{ {
boolean ispos; int i;
int lp,rp;
printf("Playing sound %d, digimap %d\n", sound, DigiMap[sound]); //printf("Playing sound %d, digimap %d\n", sound, DigiMap[sound]);
fflush(stdout); //fflush(stdout);
if (DigiMap[sound] != -1) { if (DigiMap[sound] != -1) {
alSourceStop(*sources); /* TODO: openal bug? (need to stop before play) */
alSourcei(*sources, AL_BUFFER, buffers[DigiMap[sound]]); for (i = 0; i < 4; i++) {
alSourcePlay(*sources); if (alSourceIsPlaying(sources[i]) == AL_FALSE) {
//alSourceStop(*sources);
alSourcefv(sources[i], AL_POSITION, gval);
alSource3f(sources[i], AL_DIRECTION, -pval[0], 0.0f, -pval[2]);
alSourcei(sources[i], AL_BUFFER, buffers[DigiMap[sound]]);
alSourcePlay(sources[i]);
break;
}
}
} }
}
lp = LeftPosition;
rp = RightPosition;
LeftPosition = 0;
RightPosition = 0;
ispos = nextsoundpos; /* TODO: velocity ?! */
nextsoundpos = false; void UpdateSoundLoc(fixed x, fixed y, int angle)
{
pval[0] = gval[0] = x >> 15;
pval[1] = 0.0f;
pval[2] = gval[2] = y >> 15;
alListenerfv(AL_POSITION, pval);
pval[3] = 0.0f;
pval[4] = 1.0f;
pval[5] = 0.0f;
pval[0] *= sin(angle * PI / 180.0f);
pval[2] *= cos(angle * PI / 180.0f);
alListenerfv(AL_ORIENTATION, pval);
}
return false; void PlaySoundLocGlobal(word sound, fixed x, fixed y)
{
ALfloat val[3];
int i;
//printf("Playing sound %d, digimap %d\n", sound, DigiMap[sound]);
//fflush(stdout);
if (DigiMap[sound] != -1) {
/* TODO: openal bug? (need to stop before play) */
for (i = 0; i < 4; i++) {
if (alSourceIsPlaying(sources[i]) == AL_FALSE) {
//alSourceStop(*sources);
val[0] = x >> 15;
val[1] = 0.0f;
val[2] = y >> 15;
alSourcefv(sources[i], AL_POSITION, val);
alSourcei(sources[i], AL_BUFFER, buffers[DigiMap[sound]]);
alSourcePlay(sources[i]);
break;
}
}
}
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -274,8 +293,21 @@ boolean SD_PlaySound(soundnames sound) ...@@ -274,8 +293,21 @@ boolean SD_PlaySound(soundnames sound)
// no sound is playing // no sound is playing
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/* TODO: SD_IsSoundPlaying or something? */
word SD_SoundPlaying(void) word SD_SoundPlaying(void)
{ {
int i;
/* Watch out for any looped sounds */
for (i = 0; i < 4; i++) {
if (alSourceIsPlaying(sources[i]) == AL_TRUE) {
ALint ret;
alGetSourcei(sources[i], AL_LOOPING, &ret);
if (ret == AL_FALSE)
return true;
}
}
return false; return false;
} }
...@@ -284,8 +316,14 @@ word SD_SoundPlaying(void) ...@@ -284,8 +316,14 @@ word SD_SoundPlaying(void)
// SD_StopSound() - if a sound is playing, stops it // SD_StopSound() - if a sound is playing, stops it
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void SD_StopSound(void) void SD_StopSound()
{ {
//int i;
/* TODO: this crashes for some reason... */
//for (i = 0; i < 4; i++)
// if (alSourceIsPlaying(sources[i]) == AL_TRUE)
// alSourceStop(sources[i]);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -295,8 +333,7 @@ void SD_StopSound(void) ...@@ -295,8 +333,7 @@ void SD_StopSound(void)
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void SD_WaitSoundDone(void) void SD_WaitSoundDone(void)
{ {
while (SD_SoundPlaying()) while (SD_SoundPlaying());
;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* SDM = 2 */ /* SDM = 2 */
/* SOD = 3 */ /* SOD = 3 */
#ifndef WMODE #ifndef WMODE
#define WMODE 1 #define WMODE 0
#endif #endif
#if WMODE == 0 #if WMODE == 0
......
...@@ -254,11 +254,12 @@ void DrawFace (void) ...@@ -254,11 +254,12 @@ void DrawFace (void)
int facecount; int facecount;
void UpdateFace (void) void UpdateFace (void)
{ {
if (SD_SoundPlaying() == GETGATLINGSND) /* TODO: GETGATLINGSND is an adlib sound... :( */
return; //if (SD_SoundPlaying() == GETGATLINGSND)
// return;
facecount += tics; facecount += tics;
if (facecount > US_RndT()) if (facecount > US_RndT())
......
...@@ -258,7 +258,6 @@ static char buf[10]; ...@@ -258,7 +258,6 @@ static char buf[10];
break; break;
} }
} }
SD_StopDigitized();
#endif #endif
} }
......
...@@ -61,9 +61,6 @@ ...@@ -61,9 +61,6 @@
#define MINACTORDIST 0x10000l // minimum dist from player center #define MINACTORDIST 0x10000l // minimum dist from player center
// to any actor center // to any actor center
#undef PI
#define PI 3.141592657
#define GLOBAL1 (1l<<16) #define GLOBAL1 (1l<<16)
#define TILEGLOBAL GLOBAL1 #define TILEGLOBAL GLOBAL1
#define TILESHIFT 16l #define TILESHIFT 16l
...@@ -422,8 +419,6 @@ enum { ...@@ -422,8 +419,6 @@ enum {
============================================================================= =============================================================================
*/ */
typedef long fixed;
typedef enum { typedef enum {
di_north, di_north,
di_east, di_east,
...@@ -768,9 +763,6 @@ void DrawAllPlayBorderSides (void); ...@@ -768,9 +763,6 @@ void DrawAllPlayBorderSides (void);
#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1)))) #define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1))))
#define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y) #define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y)
void PlaySoundLocGlobal(word s,fixed gx,fixed gy);
void UpdateSoundLoc(void);
/* /*
============================================================================= =============================================================================
......
...@@ -26,124 +26,6 @@ int ElevatorBackTo[]={1,1,7,3,5,3}; ...@@ -26,124 +26,6 @@ int ElevatorBackTo[]={1,1,7,3,5,3};
//=========================================================================== //===========================================================================
/*
==========================
=
= SetSoundLoc - Given the location of an object (in terms of global
= coordinates, held in globalsoundx and globalsoundy), munges the values
= for an approximate distance from the left and right ear, and puts
= those values into leftchannel and rightchannel.
=
= JAB
=
==========================
*/
fixed globalsoundx,globalsoundy;
int leftchannel,rightchannel;
#define ATABLEMAX 15
byte righttable[ATABLEMAX][ATABLEMAX * 2] = {
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 0, 0, 0, 0, 0, 1, 3, 5, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 4, 0, 0, 0, 0, 0, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 4, 1, 0, 0, 0, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 5, 4, 2, 1, 0, 1, 2, 3, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 5, 4, 3, 2, 2, 3, 3, 5, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 4, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 5, 5, 6, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8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8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}
};
void SetSoundLoc(fixed gx,fixed gy)
{
fixed xt,yt;
int x,y;
//
// translate point to view centered coordinates
//
gx -= viewx;
gy -= viewy;
//
// calculate newx
//
xt = FixedByFrac(gx,viewcos);
yt = FixedByFrac(gy,viewsin);
x = (xt - yt) >> TILESHIFT;
//
// calculate newy
//
xt = FixedByFrac(gx,viewsin);
yt = FixedByFrac(gy,viewcos);
y = (yt + xt) >> TILESHIFT;
if (y >= ATABLEMAX)
y = ATABLEMAX - 1;
else if (y <= -ATABLEMAX)
y = -ATABLEMAX;
if (x < 0)
x = -x;
if (x >= ATABLEMAX)
x = ATABLEMAX - 1;
leftchannel = lefttable[x][y + ATABLEMAX];
rightchannel = righttable[x][y + ATABLEMAX];
}
/*
==========================
=
= SetSoundLocGlobal - Sets up globalsoundx & globalsoundy and then calls
= UpdateSoundLoc() to transform that into relative channel volumes. Those
= values are then passed to the Sound Manager so that they'll be used for
= the next sound played (if possible).
=
==========================
*/
void PlaySoundLocGlobal(word s,fixed gx,fixed gy)
{
SetSoundLoc(gx,gy);
SD_PositionSound(leftchannel,rightchannel);
if (SD_PlaySound(s))
{
globalsoundx = gx;
globalsoundy = gy;
}
}
void UpdateSoundLoc(void)
{
if (SoundPositioned)
{
SetSoundLoc(globalsoundx,globalsoundy);
SD_SetPosition(leftchannel,rightchannel);
}
}
/* /*
========================== ==========================
= =
...@@ -152,10 +34,9 @@ void UpdateSoundLoc(void) ...@@ -152,10 +34,9 @@ void UpdateSoundLoc(void)
========================== ==========================
*/ */
void ClearMemory (void) void ClearMemory()
{ {
SD_StopDigitized(); MM_SortMem();
MM_SortMem ();
} }
/* /*
...@@ -589,9 +470,9 @@ void SetupGameLevel (void) ...@@ -589,9 +470,9 @@ void SetupGameLevel (void)
} }
if (demoplayback || demorecord) if (demoplayback || demorecord)
US_InitRndT (false); US_InitRndT(false);
else else
US_InitRndT (true); US_InitRndT(true);
// //
// load the level // load the level
...@@ -814,8 +695,6 @@ void DrawPlayScreen() ...@@ -814,8 +695,6 @@ void DrawPlayScreen()
DrawScore(); DrawScore();
} }
//========================================================================== //==========================================================================
/* /*
...@@ -878,8 +757,7 @@ void FinishDemoRecord (void) ...@@ -878,8 +757,7 @@ void FinishDemoRecord (void)
} }
} }
MM_FreePtr(&demobuffer);
MM_FreePtr (&demobuffer);
} }
//========================================================================== //==========================================================================
......
...@@ -643,7 +643,7 @@ void CheckKeys (void) ...@@ -643,7 +643,7 @@ void CheckKeys (void)
STR_CHEATER4"\n" STR_CHEATER4"\n"
STR_CHEATER5); STR_CHEATER5);
UNCACHEGRCHUNK(STARTFONT+1); CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown(); IN_ClearKeysDown();
IN_Ack(); IN_Ack();
...@@ -663,7 +663,7 @@ void CheckKeys (void) ...@@ -663,7 +663,7 @@ void CheckKeys (void)
ClearSplitVWB (); ClearSplitVWB ();
Message("Debugging keys are\nnow available!"); Message("Debugging keys are\nnow available!");
UNCACHEGRCHUNK(STARTFONT+1); CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown(); IN_ClearKeysDown();
IN_Ack(); IN_Ack();
...@@ -687,7 +687,7 @@ void CheckKeys (void) ...@@ -687,7 +687,7 @@ void CheckKeys (void)
"then, you already know\n" "then, you already know\n"
"that - right, Cheatmeister?!"); "that - right, Cheatmeister?!");
UNCACHEGRCHUNK(STARTFONT+1); CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown(); IN_ClearKeysDown();
IN_Ack(); IN_Ack();
...@@ -1333,8 +1333,7 @@ void PlayLoop() ...@@ -1333,8 +1333,7 @@ void PlayLoop()
gamestate.TimeCount += tics; gamestate.TimeCount += tics;
SD_Poll (); UpdateSoundLoc(player->x, player->y, player->angle);
UpdateSoundLoc(); // JAB
if (screenfaded) if (screenfaded)
VW_FadeIn (); VW_FadeIn ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment