git-svn-id: https://svn.eduke32.com/eduke32@219 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2006-07-13 23:13:06 +00:00
parent c120d9f915
commit c8589f5b9a
7 changed files with 132 additions and 44 deletions

View file

@ -7212,7 +7212,7 @@ long setgamemode(char davidoption, long daxdim, long daydim, long dabpp)
setview(0L,0L,xdim-1,ydim-1);
clearallviews(0L);
setbrightness(curbrightness,palette,0);
setbrightness(curbrightness,&palette[0],0);
if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); }

View file

@ -521,14 +521,6 @@ int handleevents(void)
ProcessInputDevices();
#ifdef DEBUGGINGAIDS
// break to the debugger if KP- is pressed
if (IsDebuggerPresent() && keystatus[0x4a]) {
keystatus[0x4a] = 0;
DebugBreak();
}
#endif
if (!appactive || quitevent) rv = -1;
sampletimer();
@ -1341,6 +1333,8 @@ static void ProcessInputDevices(void)
if (k == DIK_PAUSE) continue; // fucking pause
//if (IsDebuggerPresent() && k == DIK_F12) continue;
// hook in the osd
if (OSD_HandleKey(k, (didod[i].dwData & 0x80)) != 0) {
SetKey(k, (didod[i].dwData & 0x80) == 0x80);

View file

@ -86,7 +86,7 @@ AUDIOLIBOBJ=$(AUDIOLIB_JFAUD)
$(OBJ)osdcmds.$o \
$(JMACTOBJ) \
$(AUDIOLIBOBJ) \
$(OBJ)winbits.$o $(OBJ)gameres.res $(OBJ)startwin.game.$o
$(OBJ)winbits.$o $(OBJ)gameres.res $(OBJ)startwin.game.$o $(OBJ)startdlg.$o
EDITOROBJS=$(OBJ)astub.$o \
$(OBJ)buildres.res

View file

@ -140,6 +140,7 @@ typedef struct {
JFAudMixerChannel *chan;
int owner; // sprite number
int soundnum; // sound number
bool done;
} SoundChannel;
static SoundChannel *chans = NULL;
@ -150,9 +151,10 @@ static bool havemidi = false, havewave = false;
static void stopcallback(int r)
{
jfaud->FreeSound(chans[r].chan);
chans[r].chan = NULL;
chans[r].owner = -1;
chans[r].done = true;
// jfaud->FreeSound(chans[r].chan);
// chans[r].chan = NULL;
// chans[r].owner = -1;
}
void testcallback(unsigned long num)
@ -163,7 +165,7 @@ static int keephandle(JFAudMixerChannel *handle, int soundnum, int owner)
{
int i, freeh=-1;
for (i=NumVoices-1;i>=0;i--) {
if ((!chans[i].chan || !jfaud->IsValidSound(chans[i].chan)) && freeh<0) freeh=i;
if (!chans[i].chan && freeh<0) freeh=i;
else if (chans[i].chan == handle) { freeh=i; break; }
}
if (freeh<0) {
@ -174,6 +176,7 @@ static int keephandle(JFAudMixerChannel *handle, int soundnum, int owner)
chans[freeh].chan = handle;
chans[freeh].soundnum = soundnum;
chans[freeh].owner = owner;
chans[freeh].done = false;
return freeh;
}
@ -227,10 +230,6 @@ void SoundStartup(void)
havewave = true;
for (i=NumVoices-1; i>=0; i--) {
chans[i].owner = -1;
}
if (jfaud->InitMIDI(NULL)) havemidi = true;
OSD_RegisterFunction("setsoundfilter","setsoundfilter: 0=nearest 1=linear 2=4point",osdcmd_setsoundfilter);
@ -260,8 +259,10 @@ void AudioUpdate(void)
if (!jfaud) return;
if (havewave)
for (i=NumVoices-1; i>=0; i--) {
if (chans[i].chan && !jfaud->IsValidSound(chans[i].chan))
chans[i].chan = NULL;
if (!chans[i].done) continue;
if (chans[i].chan) jfaud->FreeSound(chans[i].chan);
chans[i].chan = NULL;
chans[i].done = false;
}
jfaud->Update(false); // don't age the cache here
}
@ -316,9 +317,9 @@ int isspritemakingsound(short i, int num) // if num<0, check if making any sound
if (!jfaud || !havewave) return 0;
for (j=NumVoices-1; j>=0; j--) {
if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan)) continue;
if (chans[j].owner == i)
if (num < 0 || chans[j].soundnum == num) n++;
if (chans[j].done || !chans[j].chan) continue;
if (chans[j].owner != i) continue;
if (num < 0 || chans[j].soundnum == num) n++;
}
return n;
}
@ -329,7 +330,7 @@ int issoundplaying(short i, int num)
if (!jfaud || !havewave) return 0;
for (j=NumVoices-1; j>=0; j--) {
if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan)) continue;
if (chans[j].done || !chans[j].chan) continue;
if (chans[j].soundnum == num) n++;
}
@ -364,7 +365,7 @@ int xyzsound(short num, short i, long x, long y, long z)
) return -1;
for (j=NumVoices-1; j>=0; j--) {
if (!chans[j].chan || chans[j].owner < 0) continue;
if (chans[j].done || !chans[j].chan || chans[j].owner < 0) continue;
if (soundm[ chans[j].soundnum ] & SOUNDM_DUKE) return -1;
}
}
@ -502,11 +503,11 @@ void stopsound(short num)
if (!jfaud || !havewave) return;
for (j=NumVoices-1;j>=0;j--) {
if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].soundnum != num) continue;
if (chans[j].done || !chans[j].chan || chans[j].soundnum != num) continue;
jfaud->FreeSound(chans[j].chan);
chans[j].chan = NULL;
chans[j].owner = -1;
chans[j].done = false;
}
}
@ -516,11 +517,11 @@ void stopspritesound(short num, short i)
if (!jfaud || !havewave) return;
for (j=NumVoices-1;j>=0;j--) {
if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].owner != i || chans[j].soundnum != num) continue;
if (chans[j].done || !chans[j].chan || chans[j].owner != i || chans[j].soundnum != num) continue;
jfaud->FreeSound(chans[j].chan);
chans[j].chan = NULL;
chans[j].owner = -1;
chans[j].done = false;
return;
}
}
@ -531,11 +532,11 @@ void stopenvsound(short num, short i)
if (!jfaud || !havewave) return;
for (j=NumVoices-1;j>=0;j--) {
if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].owner != i) continue;
if (chans[j].done || !chans[j].chan || chans[j].owner != i) continue;
jfaud->FreeSound(chans[j].chan);
chans[j].chan = NULL;
chans[j].owner = -1;
chans[j].done = false;
}
}
@ -574,7 +575,7 @@ void pan3dsound(void)
0.0, 1.0, 0.0);
for (j=NumVoices-1; j>=0; j--) {
if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].owner < 0) continue;
if (chans[j].done || !chans[j].chan || chans[j].owner < 0) continue;
global = 0;
gain = 1.0;
@ -726,3 +727,32 @@ static int osdcmd_setsoundfilter(const osdfuncparm_t *parm)
DefaultFilter = (JFAudMixerChannel::Filter)filt;
return OSDCMD_OK;
}
int EnumAudioDevs(struct audioenumdrv **wave, struct audioenumdev **midi, struct audioenumdev **cda)
{
char **enumerdrv, *defdrv;
int i;
bool isdefdrv, isdefdev;
struct audioenumdev **d;
*wave = NULL;
//*midi = *cda = NULL;
enumerdrv = JFAud::EnumerateWaveDevices(NULL, &defdrv);
if (enumerdrv) {
*wave = (struct audioenumdrv *)calloc(1,sizeof(struct audioenumdrv));
(*wave)->def = defdrv;
(*wave)->drvs = enumerdrv;
(*wave)->devs = NULL;
d = &(*wave)->devs;
for (i=0; enumerdrv[i]; i++) {
*d = (struct audioenumdev *)calloc(1,sizeof(struct audioenumdev));
(*d)->devs = JFAud::EnumerateWaveDevices(enumerdrv[i], &(*d)->def);
(*d)->next = NULL;
d = &(*d)->next;
}
}
return 0;
}

View file

@ -29,16 +29,16 @@ char haltsoundhack;
short callsound(short sn,short whatsprite)
{
short i;
if(haltsoundhack)
{
haltsoundhack = 0;
return -1;
}
// initprintf("begin callsound(%d,%d)\n",sn,whatsprite);
i = headspritesect[sn];
while(i >= 0)
{
// initprintf("callsound(%d,%d) i=%d T1-6=%d,%d,%d,%d,%d,%d PN=%d SLT=%d SHT=%d\n",sn,whatsprite,i,T1,T2,T3,T4,T5,T6,PN,SLT,SHT);
if( PN == MUSICANDSFX && SLT < 1000 )
{
if(whatsprite == -1) whatsprite = i;
@ -51,7 +51,8 @@ short callsound(short sn,short whatsprite)
{
spritesound(SLT,whatsprite);
if(SHT && SLT != SHT && SHT < NUM_SOUNDS)
stopspritesound(SHT,whatsprite);
stopspritesound(SHT,T6);
T6 = whatsprite;
}
if( (sector[SECT].lotag&0xff) != 22)
@ -62,13 +63,16 @@ short callsound(short sn,short whatsprite)
{
if(SHT) spritesound(SHT,whatsprite);
if( (soundm[SLT]&1) || ( SHT && SHT != SLT ) )
stopspritesound(SLT,whatsprite);
stopspritesound(SLT,T6);
T6 = whatsprite;
T1 = 0;
}
// initprintf("end callsound(%d,%d)\n",sn,whatsprite);
return SLT;
}
i = nextspritesect[i];
}
// initprintf("end callsound(%d,%d) -1\n",sn,whatsprite);
return -1;
}

View file

@ -52,4 +52,16 @@ void MusicStartup( void );
void MusicShutdown( void );
void AudioUpdate(void);
struct audioenumdev {
char *def;
char **devs;
struct audioenumdev *next;
};
struct audioenumdrv {
char *def;
char **drvs;
struct audioenumdev *devs;
};
int EnumAudioDevs(struct audioenumdrv **wave, struct audioenumdev **midi, struct audioenumdev **cda);
#endif

View file

@ -3,6 +3,7 @@
#endif
#include "duke3d.h"
#include "sounds.h"
#include "build.h"
#include "winlayer.h"
@ -23,6 +24,8 @@
#define TAB_GAME 1
#define TAB_MESSAGES 2
static struct audioenumdrv *wavedevs = NULL;
static struct {
int fullscreen;
int xdim, ydim, bpp;
@ -35,12 +38,17 @@ static HWND startupdlg = NULL;
static HWND pages[3] = { NULL, NULL, NULL };
static int done = -1, mode = TAB_CONFIG;
#define POPULATE_VIDEO 1
#define POPULATE_CONFIG 2
#define POPULATE_GAME 4
static void PopulateForm(int pgs)
{
HWND hwnd;
if (pgs & (1<<TAB_CONFIG)) {
int i,j;
char buf[64];
char buf[256];
int i,j;
if (pgs & POPULATE_VIDEO) {
int mode;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
@ -58,8 +66,6 @@ static void PopulateForm(int pgs)
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd);
for (i=0; i<validmodecnt; i++) {
if (validmode[i].fs != settings.fullscreen) continue;
@ -70,12 +76,39 @@ static void PopulateForm(int pgs)
ComboBox_SetItemData(hwnd, j, i);
if (i == mode) ComboBox_SetCurSel(hwnd, j);
}
}
if (pgs & POPULATE_CONFIG) {
struct audioenumdev *d;
char *n;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
ComboBox_ResetContent(hwnd);
if (wavedevs) {
d = wavedevs->devs;
for (i=0; wavedevs->drvs[i]; i++) {
strcpy(buf, wavedevs->drvs[i]);
if (d->devs) {
strcat(buf, ":");
n = buf + strlen(buf);
for (j=0; d->devs[j]; j++) {
strcpy(n, d->devs[j]);
ComboBox_AddString(hwnd, buf);
}
} else {
ComboBox_AddString(hwnd, buf);
}
d = d->next;
}
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), (settings.usemouse ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED));
}
if (pgs & (1<<TAB_GAME)) {
if (pgs & POPULATE_GAME) {
struct grpfile *fg;
int i, j;
char buf[128+BMAX_PATH];
@ -102,7 +135,7 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
switch (LOWORD(wParam)) {
case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen;
PopulateForm(1<<TAB_CONFIG);
PopulateForm(POPULATE_VIDEO);
return TRUE;
case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE) {
@ -465,7 +498,9 @@ int startwin_run(void)
done = -1;
ScanGroups();
#ifdef JFAUD
EnumAudioDevs(&wavedevs, NULL, NULL);
#endif
SetPage(TAB_CONFIG);
EnableConfig(1);
@ -504,6 +539,19 @@ int startwin_run(void)
duke3dgrp = settings.selectedgrp;
}
#ifdef JFAUD
if (wavedevs) {
struct audioenumdev *d, *e;
free(wavedevs->drvs);
for (e=wavedevs->devs; e; e=d) {
d = e->next;
if (e->devs) free(e->devs);
free(e);
}
free(wavedevs);
}
#endif
return done;
}