diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index 0d38726e2..a44a9d291 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -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); } diff --git a/polymer/build/src/winlayer.c b/polymer/build/src/winlayer.c index 3160abe3c..88a27377f 100644 --- a/polymer/build/src/winlayer.c +++ b/polymer/build/src/winlayer.c @@ -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); diff --git a/polymer/eduke32/Makefile.msvc b/polymer/eduke32/Makefile.msvc index 2b66c52d9..00dc22d59 100644 --- a/polymer/eduke32/Makefile.msvc +++ b/polymer/eduke32/Makefile.msvc @@ -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 diff --git a/polymer/eduke32/source/jfaud_sounds.cpp b/polymer/eduke32/source/jfaud_sounds.cpp index af7c500ff..0234f5c88 100644 --- a/polymer/eduke32/source/jfaud_sounds.cpp +++ b/polymer/eduke32/source/jfaud_sounds.cpp @@ -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; +} + diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 82a8e03b2..889da2302 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -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; } diff --git a/polymer/eduke32/source/sounds.h b/polymer/eduke32/source/sounds.h index d7a26ee42..25a989b87 100644 --- a/polymer/eduke32/source/sounds.h +++ b/polymer/eduke32/source/sounds.h @@ -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 diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index 65e9616f8..7b6441e0f 100755 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -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<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<drvs); + for (e=wavedevs->devs; e; e=d) { + d = e->next; + if (e->devs) free(e->devs); + free(e); + } + free(wavedevs); + } +#endif + return done; }