Commit 2757f756 authored by Steven Fuller's avatar Steven Fuller

Initial (very hackish) OpenAL Support.

parent c030b94b
......@@ -135,7 +135,6 @@ extern boolean SD_MusicPlaying(void),
extern word SD_SoundPlaying(void);
extern void SD_SetDigiDevice(SDSMode),
SD_PlayDigitized(word which,int leftpos,int rightpos),
SD_StopDigitized(void),
SD_Poll(void);
......
......@@ -70,6 +70,8 @@ static word sqMode,sqFadeStep;
/* ------------------------------------------------------------------------ */
ALuint *sources;
ALuint *buffers;
void *cc;
void SD_StopDigitized(void)
......@@ -84,10 +86,6 @@ void SD_SetPosition(int leftpos,int rightpos)
{
}
void SD_PlayDigitized(word which,int leftpos,int rightpos)
{
}
void SD_SetDigiDevice(SDSMode mode)
{
}
......@@ -122,14 +120,86 @@ boolean SD_SetMusicMode(SMMode mode)
///////////////////////////////////////////////////////////////////////////
void SD_Startup(void)
{
int i;
if (SD_Started)
return;
for (i = 0; i < LASTSOUND; i++)
DigiMap[i] = -1;
cc = alcCreateContext(NULL);
if (cc == NULL)
printf("alcCreateContext failed..\n");
else {
word *SoundList = PM_GetPage(ChunksInFile - 1);
PageListStruct *page = &PMPages[ChunksInFile - 1];
int p = page->length;
int x = 0, w, y, z;
for (i = 0; i < p / 2; i += 2) {
w = *(SoundList + i);
y = *(SoundList + i+1);
page = &PMPages[w + PMSoundStart];
if (page->length == 0) {
x++; // count it?
continue;
}
for (z = 0; z < y; w++, z++) {
page = &PMPages[w + PMSoundStart];
z += page->length;
}
x++;
}
buffers = (ALuint *)malloc(sizeof(ALuint) * x);
if (alGenBuffers(x, buffers) != x)
printf("OpenAL buffer allocation problem\n");
x = 0;
for (i = 0; i < p / 2; i += 2) {
byte *dat;
w = *(SoundList + i);
y = *(SoundList + i+1);
page = &PMPages[w + PMSoundStart];
if (page->length == 0) {
x++; // count it?
continue;
}
if (y == 0){
printf("wtf?\n");
continue;
}
dat = (byte *)malloc(y);
for (z = 0; z < y; w++) {
page = &PMPages[w + PMSoundStart];
memcpy(dat+z, PM_GetPage(w + PMSoundStart), page->length);
z += page->length;
}
alBufferData(buffers[x], AL_FORMAT_MONO8, dat, y, 6896);
if(alGetError() != AL_NO_ERROR) {
printf("AL error\n");
}
free(dat);
x++;
}
sources = (ALuint *)malloc(sizeof(ALuint) * 1);
alGenSources(1, sources);
}
SD_Started = true;
}
......@@ -178,6 +248,15 @@ boolean SD_PlaySound(soundnames sound)
boolean ispos;
int lp,rp;
printf("Playing sound %d, digimap %d\n", sound, DigiMap[sound]);
fflush(stdout);
if (DigiMap[sound] != -1) {
alSourceStop(*sources);
alSourcei(*sources, AL_BUFFER, buffers[DigiMap[sound]]);
alSourcePlay(*sources);
}
lp = LeftPosition;
rp = RightPosition;
LeftPosition = 0;
......
......@@ -248,8 +248,7 @@ static char buf[10];
PM_GetPage(j);
break;
case sc_P:
// if (sound != -1)
// SD_PlayDigitized(sound);
/* TODO: this would play the current digital sound */
break;
case sc_Escape:
done = true;
......
......@@ -796,7 +796,7 @@ static int wolfdigimap[] =
NAZIFIRESND, 21,
SLURPIESND, 22,
YEAHSND, 32,
YEAHSND, 32,
#ifndef UPLOAD
// These are in all other episodes
......@@ -813,21 +813,21 @@ static int wolfdigimap[] =
NEINSOVASSND, 28,
DOGATTACKSND, 29,
LEVELDONESND, 30,
MECHSTEPSND, 31,
SCHEISTSND, 33,
DEATHSCREAM4SND, 34, // AIIEEE
DEATHSCREAM5SND, 35, // DEE-DEE
DONNERSND, 36, // EPISODE 4 BOSS DIE
EINESND, 37, // EPISODE 4 BOSS SIGHTING
ERLAUBENSND, 38, // EPISODE 6 BOSS SIGHTING
DEATHSCREAM6SND, 39, // FART
DEATHSCREAM7SND, 40, // GASP
DEATHSCREAM8SND, 41, // GUH-BOY!
DEATHSCREAM9SND, 42, // AH GEEZ!
KEINSND, 43, // EPISODE 5 BOSS SIGHTING
MEINSND, 44, // EPISODE 6 BOSS DIE
ROSESND, 45, // EPISODE 5 BOSS DIE
MECHSTEPSND, 31,
SCHEISTSND, 33,
DEATHSCREAM4SND, 34, // AIIEEE
DEATHSCREAM5SND, 35, // DEE-DEE
DONNERSND, 36, // EPISODE 4 BOSS DIE
EINESND, 37, // EPISODE 4 BOSS SIGHTING
ERLAUBENSND, 38, // EPISODE 6 BOSS SIGHTING
DEATHSCREAM6SND, 39, // FART
DEATHSCREAM7SND, 40, // GASP
DEATHSCREAM8SND, 41, // GUH-BOY!
DEATHSCREAM9SND, 42, // AH GEEZ!
KEINSND, 43, // EPISODE 5 BOSS SIGHTING
MEINSND, 44, // EPISODE 6 BOSS DIE
ROSESND, 45, // EPISODE 5 BOSS DIE
#endif
#else
......@@ -852,14 +852,14 @@ static int wolfdigimap[] =
NAZIFIRESND, 17,
SLURPIESND, 18,
LEVELDONESND, 22,
DEATHSCREAM4SND, 23, // AIIEEE
DEATHSCREAM4SND, 23, // AIIEEE
DEATHSCREAM3SND, 23, // DOUBLY-MAPPED!!!
DEATHSCREAM5SND, 24, // DEE-DEE
DEATHSCREAM6SND, 25, // FART
DEATHSCREAM7SND, 26, // GASP
DEATHSCREAM8SND, 27, // GUH-BOY!
DEATHSCREAM9SND, 28, // AH GEEZ!
GETGATLINGSND, 38, // Got Gat replacement
DEATHSCREAM5SND, 24, // DEE-DEE
DEATHSCREAM6SND, 25, // FART
DEATHSCREAM7SND, 26, // GASP
DEATHSCREAM8SND, 27, // GUH-BOY!
DEATHSCREAM9SND, 28, // AH GEEZ!
GETGATLINGSND, 38, // Got Gat replacement
#ifndef SPEARDEMO
DOGBARKSND, 1,
......@@ -867,16 +867,16 @@ static int wolfdigimap[] =
SPIONSND, 19,
NEINSOVASSND, 20,
DOGATTACKSND, 21,
TRANSSIGHTSND, 29, // Trans Sight
TRANSDEATHSND, 30, // Trans Death
WILHELMSIGHTSND, 31, // Wilhelm Sight
WILHELMDEATHSND, 32, // Wilhelm Death
UBERDEATHSND, 33, // Uber Death
KNIGHTSIGHTSND, 34, // Death Knight Sight
KNIGHTDEATHSND, 35, // Death Knight Death
ANGELSIGHTSND, 36, // Angel Sight
ANGELDEATHSND, 37, // Angel Death
GETSPEARSND, 39, // Got Spear replacement
TRANSSIGHTSND, 29, // Trans Sight
TRANSDEATHSND, 30, // Trans Death
WILHELMSIGHTSND, 31, // Wilhelm Sight
WILHELMDEATHSND, 32, // Wilhelm Death
UBERDEATHSND, 33, // Uber Death
KNIGHTSIGHTSND, 34, // Death Knight Sight
KNIGHTDEATHSND, 35, // Death Knight Death
ANGELSIGHTSND, 36, // Angel Sight
ANGELDEATHSND, 37, // Angel Death
GETSPEARSND, 39, // Got Spear replacement
#endif
#endif
LASTSOUND
......
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