diff --git a/programs/develop/sdk/trunk/sound/include/snd.inc b/programs/develop/sdk/trunk/sound/include/snd.inc index 3f3b0f803c..265d121982 100644 --- a/programs/develop/sdk/trunk/sound/include/snd.inc +++ b/programs/develop/sdk/trunk/sound/include/snd.inc @@ -16,15 +16,19 @@ SRV_GETVERSION equ 0 SND_CREATE_BUFF equ 1 SND_DESTROY_BUFF equ 2 SND_SETFORMAT equ 3 -SND_RESET equ 4 -SND_SETPOS equ 5 -SND_SETBUFF equ 6 -SND_SETVOLUME equ 7 -SND_GETVOLUME equ 8 +SND_GETFORMAT equ 4 +SND_RESET equ 5 +SND_SETPOS equ 6 +SND_GETPOS equ 7 +SND_SETBUFF equ 8 SND_OUT equ 9 SND_PLAY equ 10 SND_STOP equ 11 -SND_SETPAN equ 12 +SND_SETVOLUME equ 12 +SND_GETVOLUME equ 13 +SND_SETPAN equ 14 +SND_GETPAN equ 15 +SND_GETBUFFSIZE equ 16 DEV_SET_BUFF equ 4 DEV_NOTIFY equ 5 diff --git a/programs/develop/sdk/trunk/sound/include/sound.h b/programs/develop/sdk/trunk/sound/include/sound.h index f42aed276e..416bebaefb 100644 --- a/programs/develop/sdk/trunk/sound/include/sound.h +++ b/programs/develop/sdk/trunk/sound/include/sound.h @@ -7,12 +7,15 @@ extern "C" { #endif -#define SOUND_VERSION 5 +#define SOUND_VERSION 5 #define PCM_ALL 0 -#define PCM_STATIC 0x80000000 -#define PCM_FILTER 0x40000000 -#define PCM_FLOAT 0x20000000 + +#define PCM_OUT 0x08000000 +#define PCM_RING 0x10000000 +#define PCM_STATIC 0x20000000 +#define PCM_FLOAT 0x40000000 +#define PCM_FILTER 0x80000000 #define PCM_2_16_48 1 #define PCM_1_16_48 2 @@ -55,51 +58,50 @@ extern "C" #define SND_CREATE_BUFF 1 #define SND_DESTROY_BUFF 2 #define SND_SETFORMAT 3 -#define SND_RESET 4 -#define SND_SETPOS 5 -#define SND_SETBUFF 6 -#define SND_SETVOLUME 7 -#define SND_GETVOLUME 8 +#define SND_GETFORMAT 4 +#define SND_RESET 5 +#define SND_SETPOS 6 +#define SND_GETPOS 7 +#define SND_SETBUFF 8 #define SND_OUT 9 -#define SND_PLAY 10 -#define SND_STOP 11 +#define SND_PLAY 10 +#define SND_STOP 11 +#define SND_SETVOLUME 12 +#define SND_GETVOLUME 13 +#define SND_SETPAN 14 +#define SND_GETPAN 15 +#define SND_GETBUFFSIZE 16 + +#define PLAY_SYNC 0x80000000 typedef unsigned int SNDBUF; int _stdcall InitSound(); + SNDBUF _stdcall CreateBuffer(unsigned int format,int size); int _stdcall DestroyBuffer(SNDBUF hBuff); -int _stdcall SetBuffer(SNDBUF hBuff,void* buff, - int offs, int size); + int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); +int _stdcall GetFormat(SNDBUF hBuff); + int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); int _stdcall SetBufferPos(SNDBUF hBuff, int offset); +int _stdcall GetBufferPos(SNDBUF hBuff); +int _stdcall GetBufferSize(SNDBUF hBuff); + +int _stdcall SetBuffer(SNDBUF hBuff,void* buff, + int offs, int size); +int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); +int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags); +int _stdcall StopBuffer(SNDBUF hBuff); + int _stdcall SetVolume(SNDBUF hBuff, int left, int right); int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); int _stdcall SetPan(SNDBUF hBuff, int pan); +int _stdcall GetPan(SNDBUF hBuff); -int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); - -int _stdcall PlayBuffer(SNDBUF hBuff); -int _stdcall StopBuffer(SNDBUF hBuff); - -typedef struct -{ unsigned int riff_id; - unsigned int riff_size; - unsigned int riff_format; - - unsigned int fmt_id; - unsigned int fmt_size; - - unsigned short int wFormatTag; - unsigned short int nChannels; - unsigned int nSamplesPerSec; - unsigned int nAvgBytesPerSec; - unsigned short int nBlockAlign; - unsigned short int wBitsPerSample; - unsigned int data_id; - unsigned int data_size; -} WAVEHEADER; +int _stdcall GetMasterVol(int* vol); +int _stdcall SetMasterVol(int vol); unsigned int _stdcall test_wav(WAVEHEADER *hdr); @@ -108,4 +110,4 @@ extern "C" } #endif -#endif //_SOUND_H_ +#endif //_SOUND_H_ \ No newline at end of file diff --git a/programs/develop/sdk/trunk/sound/src/init.asm b/programs/develop/sdk/trunk/sound/src/init.asm index 680a675435..d3f16beba8 100644 --- a/programs/develop/sdk/trunk/sound/src/init.asm +++ b/programs/develop/sdk/trunk/sound/src/init.asm @@ -128,12 +128,13 @@ endp section '.data' align 16 data readable writable -szInfinity db 'INFINITY',0 -szSound db 'SOUND',0 - public hSound public hrdwSound -align 4 hSound dd ? -hrdwSound dd ? \ No newline at end of file +hrdwSound dd ? + +szInfinity db 'INFINITY',0 +szSound db 'SOUND',0 + + diff --git a/programs/develop/sdk/trunk/sound/src/setbuf.asm b/programs/develop/sdk/trunk/sound/src/setbuf.asm index d18a4376a5..312875b46d 100644 --- a/programs/develop/sdk/trunk/sound/src/setbuf.asm +++ b/programs/develop/sdk/trunk/sound/src/setbuf.asm @@ -8,7 +8,7 @@ section '.text' align 16 code readable executable extrn hSound public _SetBuffer@16 -public _PlayBuffer@4 +public _PlayBuffer@8 align 4 proc _SetBuffer@16 stdcall,str:dword, src:dword, offs:dword, size:dword @@ -44,7 +44,7 @@ proc _SetBuffer@16 stdcall,str:dword, src:dword, offs:dword, size:dword endp align 4 -proc _PlayBuffer@4 stdcall, str:dword +proc _PlayBuffer@8 stdcall, str:dword,flags:dword locals handle dd ? io_code dd ? diff --git a/programs/develop/sdk/trunk/sound/src/snd.inc b/programs/develop/sdk/trunk/sound/src/snd.inc index 3f3b0f803c..265d121982 100644 --- a/programs/develop/sdk/trunk/sound/src/snd.inc +++ b/programs/develop/sdk/trunk/sound/src/snd.inc @@ -16,15 +16,19 @@ SRV_GETVERSION equ 0 SND_CREATE_BUFF equ 1 SND_DESTROY_BUFF equ 2 SND_SETFORMAT equ 3 -SND_RESET equ 4 -SND_SETPOS equ 5 -SND_SETBUFF equ 6 -SND_SETVOLUME equ 7 -SND_GETVOLUME equ 8 +SND_GETFORMAT equ 4 +SND_RESET equ 5 +SND_SETPOS equ 6 +SND_GETPOS equ 7 +SND_SETBUFF equ 8 SND_OUT equ 9 SND_PLAY equ 10 SND_STOP equ 11 -SND_SETPAN equ 12 +SND_SETVOLUME equ 12 +SND_GETVOLUME equ 13 +SND_SETPAN equ 14 +SND_GETPAN equ 15 +SND_GETBUFFSIZE equ 16 DEV_SET_BUFF equ 4 DEV_NOTIFY equ 5 diff --git a/programs/develop/sdk/trunk/sound/src/sndgetfmt.asm b/programs/develop/sdk/trunk/sound/src/sndgetfmt.asm new file mode 100644 index 0000000000..2ad1453687 --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndgetfmt.asm @@ -0,0 +1,43 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +extrn hSound + +public _GetFormat@4 + +align 4 +proc _GetFormat@4 stdcall, str:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hSound] + lea ebx, [str] + xor ecx, ecx + + mov [handle], eax + mov [io_code], SND_GETFORMAT + mov [input], ebx + mov [inp_size], 4 + mov [output], ecx + mov [out_size], ecx + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp diff --git a/programs/develop/sdk/trunk/sound/src/sndgetmvol.asm b/programs/develop/sdk/trunk/sound/src/sndgetmvol.asm new file mode 100644 index 0000000000..0d8cf37af6 --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndgetmvol.asm @@ -0,0 +1,74 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +public _GetMasterVol@4 + +extrn hrdwSound + +align 4 +proc _GetMasterVol@4 stdcall, pvol:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hrdwSound] + mov ecx, [pvol] + xor ebx, ebx + mov [handle], eax + mov [io_code], DEV_GET_MASTERVOL + mov [input], ebx + mov [inp_size], ebx + mov [output], ecx + mov [out_size], 4 + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp + +if 0 +align 4 +proc _GetDevInfo@8 stdcall, hSrv:dword, p_info:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + mov eax, [hSrv] + xor ebx, ebx + mov ecx, [p_info] + + mov [handle], eax + mov [io_code], DEV_GET_INFO + mov [input], ebx + mov [inp_size], ebx + mov [output], ecx + mov [out_size], CTRL_INFO_SIZE + + lea eax, [handle] + stdcall CallServiceEx, eax + pop ebx + ret +endp + +end if \ No newline at end of file diff --git a/programs/develop/sdk/trunk/sound/src/sndgetpan.asm b/programs/develop/sdk/trunk/sound/src/sndgetpan.asm new file mode 100644 index 0000000000..ef473389b2 --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndgetpan.asm @@ -0,0 +1,43 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +public _GetPan@4 + +extrn hSound + +align 4 +proc _GetPan@4 stdcall, str:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hSound] + lea ebx, [str] + xor ecx, ecx + + mov [handle], eax + mov [io_code], SND_GETPAN + mov [input], ebx + mov [inp_size], 4 + mov [output], ecx + mov [out_size], ecx + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp diff --git a/programs/develop/sdk/trunk/sound/src/sndgetpos.asm b/programs/develop/sdk/trunk/sound/src/sndgetpos.asm new file mode 100644 index 0000000000..4912740c68 --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndgetpos.asm @@ -0,0 +1,43 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +extrn hSound + +public _GetBufferPos@4 + +align 4 +proc _GetBufferPos@4 stdcall, str:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hSound] + lea ebx, [str] + xor ecx, ecx + + mov [handle], eax + mov [io_code], SND_GETPOS + mov [input], ebx + mov [inp_size], 4 + mov [output], ecx + mov [out_size], ecx + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp diff --git a/programs/develop/sdk/trunk/sound/src/sndgetsize.asm b/programs/develop/sdk/trunk/sound/src/sndgetsize.asm new file mode 100644 index 0000000000..dd9e8df9db --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndgetsize.asm @@ -0,0 +1,43 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +public _GetBufferSize@4 + +extrn hSound + +align 4 +proc _GetBufferSize@4 stdcall, str:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hSound] + lea ebx, [str] + xor ecx, ecx + + mov [handle], eax + mov [io_code], SND_GETBUFFSIZE + mov [input], ebx + mov [inp_size], 4 + mov [output], ecx + mov [out_size], ecx + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp diff --git a/programs/develop/sdk/trunk/sound/src/sndgetvol.asm b/programs/develop/sdk/trunk/sound/src/sndgetvol.asm new file mode 100644 index 0000000000..dadcff1632 --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndgetvol.asm @@ -0,0 +1,44 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +public _GetVolume@12 + +extrn hSound + +align 4 +proc _GetVolume@12 stdcall, str:dword, pleft:dword,pright:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hSound] + lea ebx, [str] + lea ecx, [pleft] + mov [handle], eax + mov [io_code], SND_GETVOLUME + mov [input], ebx + mov [inp_size], 4 + mov [output], ecx + mov [out_size], 8 + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp + + diff --git a/programs/develop/sdk/trunk/sound/src/sndfmt.asm b/programs/develop/sdk/trunk/sound/src/sndsetfmt.asm similarity index 100% rename from programs/develop/sdk/trunk/sound/src/sndfmt.asm rename to programs/develop/sdk/trunk/sound/src/sndsetfmt.asm diff --git a/programs/develop/sdk/trunk/sound/src/sndsetmvol.asm b/programs/develop/sdk/trunk/sound/src/sndsetmvol.asm new file mode 100644 index 0000000000..c1d4ea1d2d --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndsetmvol.asm @@ -0,0 +1,44 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +public _SetMasterVol@4 + +extrn hrdwSound + +align 4 +proc _SetMasterVol@4 stdcall,vol:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hrdwSound] + lea ebx, [vol] + xor ecx, ecx + + mov [handle], eax + mov [io_code], DEV_SET_MASTERVOL + mov [input], ebx + mov [inp_size], 4 + mov [output], ecx + mov [out_size], ecx + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp + diff --git a/programs/develop/sdk/trunk/sound/src/sndsetpan.asm b/programs/develop/sdk/trunk/sound/src/sndsetpan.asm new file mode 100644 index 0000000000..6024fa918c --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndsetpan.asm @@ -0,0 +1,43 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +public _SetPan@8 + +extrn hSound + +align 4 +proc _SetPan@8 stdcall, str:dword, pan:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hSound] + lea ebx, [str] + xor ecx, ecx + + mov [handle], eax + mov [io_code], SND_SETPAN + mov [input], ebx + mov [inp_size], 8 + mov [output], ecx + mov [out_size], ecx + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp diff --git a/programs/develop/sdk/trunk/sound/src/sndsetvol.asm b/programs/develop/sdk/trunk/sound/src/sndsetvol.asm new file mode 100644 index 0000000000..a84847811d --- /dev/null +++ b/programs/develop/sdk/trunk/sound/src/sndsetvol.asm @@ -0,0 +1,44 @@ +format MS COFF + +include "snd.inc" +include "proc32.inc" + +section '.text' align 16 code readable executable + +public _SetVolume@12 + +extrn hSound + +align 4 +proc _SetVolume@12 stdcall, str:dword, lvol:dword,rvol:dword + locals + handle dd ? + io_code dd ? + input dd ? + inp_size dd ? + output dd ? + out_size dd ? + endl + + push ebx + push ecx + mov eax, [hSound] + lea ebx, [str] + xor ecx, ecx + + mov [handle], eax + mov [io_code], SND_SETVOLUME + mov [input], ebx + mov [inp_size], 12 + mov [output], ecx + mov [out_size], ecx + + mov eax, 68 + mov ebx, 17 + lea ecx, [handle] + int 0x40 + pop ecx + pop ebx + ret +endp + diff --git a/programs/develop/sdk/trunk/sound/src/sndvol.asm b/programs/develop/sdk/trunk/sound/src/sndvol.asm deleted file mode 100644 index ad609ca1f0..0000000000 --- a/programs/develop/sdk/trunk/sound/src/sndvol.asm +++ /dev/null @@ -1,177 +0,0 @@ -format MS COFF - -include "snd.inc" -include "proc32.inc" - -section '.text' align 16 code readable executable - -public _SetVolume@12 -public _GetVolume@12 - -public _GetMasterVol@4 -public _SetMasterVol@4 - -extrn hSound -extrn hrdwSound - -align 4 -proc _SetVolume@12 stdcall, str:dword, lvol:dword,rvol:dword - locals - handle dd ? - io_code dd ? - input dd ? - inp_size dd ? - output dd ? - out_size dd ? - endl - - push ebx - push ecx - mov eax, [hSound] - lea ebx, [str] - xor ecx, ecx - - mov [handle], eax - mov [io_code], SND_SETVOLUME - mov [input], ebx - mov [inp_size], 12 - mov [output], ecx - mov [out_size], ecx - - mov eax, 68 - mov ebx, 17 - lea ecx, [handle] - int 0x40 - pop ecx - pop ebx - ret -endp - -align 4 -proc _GetVolume@12 stdcall, str:dword, pleft:dword,pright:dword - locals - handle dd ? - io_code dd ? - input dd ? - inp_size dd ? - output dd ? - out_size dd ? - endl - - push ebx - push ecx - mov eax, [hSound] - lea ebx, [str] - lea ecx, [pleft] - mov [handle], eax - mov [io_code], SND_GETVOLUME - mov [input], ebx - mov [inp_size], 4 - mov [output], ecx - mov [out_size], 8 - - mov eax, 68 - mov ebx, 17 - lea ecx, [handle] - int 0x40 - pop ecx - pop ebx - ret -endp - -align 4 -proc _GetMasterVol@4 stdcall, pvol:dword - locals - handle dd ? - io_code dd ? - input dd ? - inp_size dd ? - output dd ? - out_size dd ? - endl - - push ebx - push ecx - mov eax, [hrdwSound] - mov ecx, [pvol] - xor ebx, ebx - mov [handle], eax - mov [io_code], DEV_GET_MASTERVOL - mov [input], ebx - mov [inp_size], ebx - mov [output], ecx - mov [out_size], 4 - - mov eax, 68 - mov ebx, 17 - lea ecx, [handle] - int 0x40 - pop ecx - pop ebx - ret -endp - -align 4 -proc _SetMasterVol@4 stdcall,vol:dword - locals - handle dd ? - io_code dd ? - input dd ? - inp_size dd ? - output dd ? - out_size dd ? - endl - - push ebx - push ecx - mov eax, [hrdwSound] - lea ebx, [vol] - xor ecx, ecx - - mov [handle], eax - mov [io_code], DEV_SET_MASTERVOL - mov [input], ebx - mov [inp_size], 4 - mov [output], ecx - mov [out_size], ecx - - mov eax, 68 - mov ebx, 17 - lea ecx, [handle] - int 0x40 - pop ecx - pop ebx - ret -endp - -if 0 -align 4 -proc _GetDevInfo@8 stdcall, hSrv:dword, p_info:dword - locals - handle dd ? - io_code dd ? - input dd ? - inp_size dd ? - output dd ? - out_size dd ? - endl - - push ebx - mov eax, [hSrv] - xor ebx, ebx - mov ecx, [p_info] - - mov [handle], eax - mov [io_code], DEV_GET_INFO - mov [input], ebx - mov [inp_size], ebx - mov [output], ecx - mov [out_size], CTRL_INFO_SIZE - - lea eax, [handle] - stdcall CallServiceEx, eax - pop ebx - ret -endp - -end if \ No newline at end of file diff --git a/programs/games/doom/trunk/d_main.c b/programs/games/doom/trunk/d_main.c index 2d712e99ff..fa371d791d 100644 --- a/programs/games/doom/trunk/d_main.c +++ b/programs/games/doom/trunk/d_main.c @@ -436,7 +436,7 @@ void D_DoomLoop (void) S_UpdateSounds (players[consoleplayer].mo);// move positional sounds D_Display (); - // I_UpdateSound(); + // I_UpdateSound(); XXX(105); } } diff --git a/programs/games/doom/trunk/h/doomdef.h b/programs/games/doom/trunk/h/doomdef.h index 60bf4826f4..7c7b2b5031 100644 --- a/programs/games/doom/trunk/h/doomdef.h +++ b/programs/games/doom/trunk/h/doomdef.h @@ -118,7 +118,7 @@ typedef enum #define MAXPLAYERS 4 // State updates, number of tics / second. -#define TICRATE 35 +#define TICRATE 30 // The current state of the game: whether we are // playing, gazing at the intermission screen, diff --git a/programs/games/doom/trunk/i_sound.c b/programs/games/doom/trunk/i_sound.c index 32388f0f6e..2325a3fbe1 100644 --- a/programs/games/doom/trunk/i_sound.c +++ b/programs/games/doom/trunk/i_sound.c @@ -49,6 +49,7 @@ rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $"; #include "doomdef.h" #include "kolibri.h" +#include "sound.h" // The number of internal mixing channels, // the samples calculated for each mixing step, @@ -57,11 +58,11 @@ rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $"; // Needed for calling the actual sound output. -#define SAMPLECOUNT 8192 +#define SAMPLECOUNT 1024 #define NUM_CHANNELS 16 // It is 2 for 16bit, and 2 for two channels. -#define BUFMUL 4 -#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) +//#define BUFMUL 4 +//#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) #define SAMPLERATE 11025 // Hz #define SAMPLESIZE 2 // 16bit @@ -76,8 +77,7 @@ int audio_fd; // Basically, samples from all active internal channels // are modifed and added, and stored in the buffer // that is submitted to the audio device. -signed short mixbuffer[MIXBUFFERSIZE]; - +signed short *mixbuffer; // The channel step amount... unsigned int channelstep[NUM_CHANNELS]; @@ -291,10 +291,17 @@ int addsfx(int sfxid, int volume, int step, int seperation) // Sanity check, clamp volume. if (rightvol < 0 || rightvol > 127) - I_Error("rightvol out of bounds"); + { + printf("rightvol out of bounds\n\r"); + rightvol = 0; + + } if (leftvol < 0 || leftvol > 127) - I_Error("leftvol out of bounds"); + { + printf("leftvol out of bounds\n\r"); + leftvol=0; + } // Get the proper lookup table piece // for this volume level??? @@ -426,8 +433,9 @@ int I_SoundIsPlaying(int handle) // This function currently supports only 16bit. // -extern DWORD hMixBuff[4]; -extern int mix_ptr; +extern SNDBUF hMixBuff; +extern unsigned int mix_offset; +extern int mix_size; void I_UpdateSound( void ) { @@ -441,7 +449,7 @@ void I_UpdateSound( void ) // Pointers in global mixbuffer, left, right, end. signed short* leftout; signed short* rightout; - signed short* leftend; +// signed short* leftend; // Step in mixbuffer, left and right, thus two. int step; @@ -449,7 +457,7 @@ void I_UpdateSound( void ) int chan; int i; int flags; - flags = 0; + int size = 0; // Left and right channel // are in global mixbuffer, alternating. @@ -459,12 +467,12 @@ void I_UpdateSound( void ) // Determine end, for left channel only // (right channel is implicit). - leftend = mixbuffer + SAMPLECOUNT*step; + // leftend = mixbuffer + SAMPLECOUNT*step; // Mix sounds into the mixing buffer. // Loop over step*SAMPLECOUNT, // that is 512 values for two channels. - for (i=0; i < 8192; i++) + for (i=0; i < mix_size/4; i++) { // Reset left/right value. dl = 0; @@ -473,12 +481,14 @@ void I_UpdateSound( void ) // Love thy L2 chache - made this a loop. // Now more channels could be set at compile time // as well. Thus loop those channels. + // flags=0; + for ( chan = 0; chan < NUM_CHANNELS; chan++ ) { // Check channel, if active. if (channels[ chan ]) { - flags=1; + // flags=1; // Get the raw data from the channel. sample = *channels[ chan ]; @@ -525,11 +535,22 @@ void I_UpdateSound( void ) // Increment current pointers in mixbuffer. leftout += step; rightout += step; +// if (flags) +// size+=4; } - if(flags) - { WaveOut(hMixBuff[mix_ptr],(char*)&mixbuffer[0],32768); - mix_ptr= (mix_ptr+1)&3; - }; + + SetBuffer(hMixBuff,mixbuffer,mix_offset,mix_size); + + + // WaveOut(hMixBuff,(char*)&mixbuffer[0],4096); + +// if(size) +// { +// WaveOut(hMixBuff,(char*)&mixbuffer[0],size); +// SetBufferPos(hMixBuff, 0); +// SetBuffer(hMixBuff,(char*)&mixbuffer[0],mix_offset,4096); +// PlayBuffer(hMixBuff, PCM_SYNC); +// }; } @@ -559,23 +580,11 @@ void I_UpdateSoundParams(int handle, int vol, int sep, int pitch) handle = vol = sep = pitch = 0; } +extern volatile int sound_state; + void I_ShutdownSound(void) { - // Wait till all pending sounds are finished. - int done = 0; - int i; - - // FIXME (below). - printf( "I_ShutdownSound: NOT finishing pending sounds\n"); - - while ( !done ) - { - for( i=0 ; i<8 && !channels[i] ; i++); - - // FIXME. No proper channel output. - //if (i==8) - done=1; - } + sound_state=0; return; } @@ -603,8 +612,8 @@ void I_InitSound() printf( " pre-cached all sound data\n"); // Now initialize mixbuffer with zero. - for ( i = 0; i< MIXBUFFERSIZE; i++ ) - mixbuffer[i] = 0; +// for ( i = 0; i< MIXBUFFERSIZE; i++ ) + // mixbuffer[i] = 0; // Finished initialization. printf("I_InitSound: sound module ready\n"); diff --git a/programs/games/doom/trunk/i_system.c b/programs/games/doom/trunk/i_system.c index 86454ed103..ab8d7f3aa9 100644 --- a/programs/games/doom/trunk/i_system.c +++ b/programs/games/doom/trunk/i_system.c @@ -91,8 +91,6 @@ int I_GetTime (void) return (tm*TICRATE)/100; } - - // // I_Init // @@ -109,10 +107,10 @@ void I_Quit (void) { // __libclog_printf("Calling I_Quit from %x\n",__builtin_return_address(0)); D_QuitNetGame (); - // I_ShutdownSound(); + I_ShutdownSound(); // I_ShutdownMusic(); M_SaveDefaults (); - I_ShutdownGraphics(); +// I_ShutdownGraphics(); exit(0); } @@ -144,6 +142,7 @@ byte* I_AllocLow(int length) // I_Error // extern boolean demorecording; +extern volatile int sound_state; void I_Error (char *error, ...) { @@ -162,6 +161,7 @@ void I_Error (char *error, ...) D_QuitNetGame (); I_ShutdownGraphics(); + sound_state=0; // getch(); exit(-1); } diff --git a/programs/games/doom/trunk/kolibc/include/kolibri.h b/programs/games/doom/trunk/kolibc/include/kolibri.h index 0595e911f2..d888282c2e 100644 --- a/programs/games/doom/trunk/kolibc/include/kolibri.h +++ b/programs/games/doom/trunk/kolibc/include/kolibri.h @@ -66,20 +66,11 @@ void _stdcall InitHeap(int heap_size); void* _stdcall UserAlloc(int size); int _stdcall UserFree(void* p); -void _stdcall GetNotify(DWORD *event); +void _stdcall GetNotify(void *event); + +void _stdcall CreateThread(void *fn, char *p_stack); -//void _stdcall CreateThread(void *fn, char *p_stack); DWORD _stdcall GetMousePos(DWORD rel_type); -int _stdcall GetService(char *srv_name); -void _stdcall GetDevInfo(DWORD hSrv,CTRL_INFO *pInfo); -int _stdcall GetMasterVol(DWORD hSrv,int* vol); -int _stdcall SetMasterVol(DWORD hSrv, int vol); -DWORD _stdcall CreateBuffer(DWORD hSrv, DWORD format); -int _stdcall DestroyBuffer(DWORD hSrv, DWORD hBuff); -int _stdcall SetBuffer(DWORD hSrv, DWORD hBuff,char* buff, - DWORD offs, int size); -int _stdcall PlayBuffer(DWORD hSrv, DWORD hBuff); -int _stdcall StopBuffer(DWORD hSrv, DWORD hBuff); void _stdcall debug_out_hex(DWORD val); void debug_out_str(char* str); @@ -99,6 +90,8 @@ int wait_for_event(int time); int wait_for_event_infinite(); void BeginDraw(void); void EndDraw(void); + +void _stdcall GetScreenSize(int *x, int*y); void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style, int captioncolor,int windowtype,int bordercolor); void _stdcall debug_out(int ch); diff --git a/programs/games/doom/trunk/kolibc/include/sound.h b/programs/games/doom/trunk/kolibc/include/sound.h new file mode 100644 index 0000000000..58eb041ba1 --- /dev/null +++ b/programs/games/doom/trunk/kolibc/include/sound.h @@ -0,0 +1,134 @@ + +#ifndef _SOUND_H_ +#define _SOUND_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SOUND_VERSION 5 + +#define PCM_ALL 0 + +#define PCM_OUT 0x08000000 +#define PCM_RING 0x10000000 +#define PCM_STATIC 0x20000000 +#define PCM_FLOAT 0x40000000 +#define PCM_FILTER 0x80000000 + +#define PCM_2_16_48 1 +#define PCM_1_16_48 2 +#define PCM_2_16_44 3 +#define PCM_1_16_44 4 +#define PCM_2_16_32 5 +#define PCM_1_16_32 6 +#define PCM_2_16_24 7 +#define PCM_1_16_24 8 +#define PCM_2_16_22 9 +#define PCM_1_16_22 10 +#define PCM_2_16_16 11 +#define PCM_1_16_16 12 +#define PCM_2_16_12 13 +#define PCM_1_16_12 14 +#define PCM_2_16_11 15 +#define PCM_1_16_11 16 +#define PCM_2_16_8 17 +#define PCM_1_16_8 18 +#define PCM_2_8_48 19 +#define PCM_1_8_48 20 +#define PCM_2_8_44 21 +#define PCM_1_8_44 22 +#define PCM_2_8_32 23 +#define PCM_1_8_32 24 +#define PCM_2_8_24 25 +#define PCM_1_8_24 26 +#define PCM_2_8_22 27 +#define PCM_1_8_22 28 +#define PCM_2_8_16 29 +#define PCM_1_8_16 30 +#define PCM_2_8_12 31 +#define PCM_1_8_12 32 +#define PCM_2_8_11 33 +#define PCM_1_8_11 34 +#define PCM_2_8_8 35 +#define PCM_1_8_8 36 + +#define SRV_GETVERSION 0 +#define SND_CREATE_BUFF 1 +#define SND_DESTROY_BUFF 2 +#define SND_SETFORMAT 3 +#define SND_GETFORMAT 4 +#define SND_RESET 5 +#define SND_SETPOS 6 +#define SND_GETPOS 7 +#define SND_SETBUFF 8 +#define SND_OUT 9 +#define SND_PLAY 10 +#define SND_STOP 11 +#define SND_SETVOLUME 12 +#define SND_GETVOLUME 13 +#define SND_SETPAN 14 +#define SND_GETPAN 15 +#define SND_GETBUFFSIZE 16 + +#define PLAY_SYNC 0x80000000 + +typedef unsigned int SNDBUF; + +int _stdcall InitSound(); + +SNDBUF _stdcall CreateBuffer(unsigned int format,int size); +int _stdcall DestroyBuffer(SNDBUF hBuff); + +int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); +int _stdcall GetFormat(SNDBUF hBuff); + +int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); +int _stdcall SetBufferPos(SNDBUF hBuff, int offset); +int _stdcall GetBufferPos(SNDBUF hBuff); +int _stdcall GetBufferSize(SNDBUF hBuff); + +int _stdcall SetBuffer(SNDBUF hBuff,void* buff, + int offs, int size); +int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); +int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags); +int _stdcall StopBuffer(SNDBUF hBuff); + +int _stdcall SetVolume(SNDBUF hBuff, int left, int right); +int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); +int _stdcall SetPan(SNDBUF hBuff, int pan); +int _stdcall GetPan(SNDBUF hBuff, int pan); + +int _stdcall GetMasterVol(int* vol); +int _stdcall SetMasterVol(int vol); + + +typedef struct +{ + unsigned int riff_id; + unsigned int riff_size; + unsigned int riff_format; + + unsigned int fmt_id; + unsigned int fmt_size; + + unsigned short int wFormatTag; + unsigned short int nChannels; + unsigned int nSamplesPerSec; + unsigned int nAvgBytesPerSec; + unsigned short int nBlockAlign; + unsigned short int wBitsPerSample; + unsigned int data_id; + unsigned int data_size; +} WAVEHEADER; + + +unsigned int _stdcall test_wav(WAVEHEADER *hdr); + +#ifdef __cplusplus +extern "C" +} +#endif + +#endif //_SOUND_H_ diff --git a/programs/games/doom/trunk/s_sound.c b/programs/games/doom/trunk/s_sound.c index 1c1381392b..aacc9f2864 100644 --- a/programs/games/doom/trunk/s_sound.c +++ b/programs/games/doom/trunk/s_sound.c @@ -47,6 +47,7 @@ rcsid[] = "$Id: s_sound.c,v 1.6 1997/02/03 22:45:12 b1 Exp $"; #include "kolibri.h" +#include "sound.h" void WriteDebug(char *); @@ -165,24 +166,20 @@ void S_StopChannel(int cnum); // allocates channel buffer, sets S_sfx lookup. // -DWORD hMixBuff[4]; -int mix_ptr; + +SNDBUF hMixBuff; +volatile int sound_state; +void sound_proc(void); +void I_UpdateSound( void ); void S_Init ( int sfxVolume, int musicVolume ) { int i; + char *thread_stack; + int ver; - printf("S_Init: default sfx volume %d\n", sfxVolume); - - InitSound(); - - hMixBuff[0]= CreateBuffer(15); - hMixBuff[1]= CreateBuffer(15); - hMixBuff[2]= CreateBuffer(15); - hMixBuff[3]= CreateBuffer(15); - numChannels = NUM_CHANNELS; // Whatever these did with DMX, these are rather dummies now. @@ -208,8 +205,120 @@ void S_Init // Note that sounds have not been cached (yet). for (i=1 ; i