DOOM alpha 4

git-svn-id: svn://kolibrios.org@374 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-02-25 09:21:19 +00:00
parent 6e47c89546
commit 72fe949f6f
23 changed files with 796 additions and 296 deletions

View File

@ -16,15 +16,19 @@ SRV_GETVERSION equ 0
SND_CREATE_BUFF equ 1 SND_CREATE_BUFF equ 1
SND_DESTROY_BUFF equ 2 SND_DESTROY_BUFF equ 2
SND_SETFORMAT equ 3 SND_SETFORMAT equ 3
SND_RESET equ 4 SND_GETFORMAT equ 4
SND_SETPOS equ 5 SND_RESET equ 5
SND_SETBUFF equ 6 SND_SETPOS equ 6
SND_SETVOLUME equ 7 SND_GETPOS equ 7
SND_GETVOLUME equ 8 SND_SETBUFF equ 8
SND_OUT equ 9 SND_OUT equ 9
SND_PLAY equ 10 SND_PLAY equ 10
SND_STOP equ 11 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_SET_BUFF equ 4
DEV_NOTIFY equ 5 DEV_NOTIFY equ 5

View File

@ -10,9 +10,12 @@ extern "C"
#define SOUND_VERSION 5 #define SOUND_VERSION 5
#define PCM_ALL 0 #define PCM_ALL 0
#define PCM_STATIC 0x80000000
#define PCM_FILTER 0x40000000 #define PCM_OUT 0x08000000
#define PCM_FLOAT 0x20000000 #define PCM_RING 0x10000000
#define PCM_STATIC 0x20000000
#define PCM_FLOAT 0x40000000
#define PCM_FILTER 0x80000000
#define PCM_2_16_48 1 #define PCM_2_16_48 1
#define PCM_1_16_48 2 #define PCM_1_16_48 2
@ -55,51 +58,50 @@ extern "C"
#define SND_CREATE_BUFF 1 #define SND_CREATE_BUFF 1
#define SND_DESTROY_BUFF 2 #define SND_DESTROY_BUFF 2
#define SND_SETFORMAT 3 #define SND_SETFORMAT 3
#define SND_RESET 4 #define SND_GETFORMAT 4
#define SND_SETPOS 5 #define SND_RESET 5
#define SND_SETBUFF 6 #define SND_SETPOS 6
#define SND_SETVOLUME 7 #define SND_GETPOS 7
#define SND_GETVOLUME 8 #define SND_SETBUFF 8
#define SND_OUT 9 #define SND_OUT 9
#define SND_PLAY 10 #define SND_PLAY 10
#define SND_STOP 11 #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; typedef unsigned int SNDBUF;
int _stdcall InitSound(); int _stdcall InitSound();
SNDBUF _stdcall CreateBuffer(unsigned int format,int size); SNDBUF _stdcall CreateBuffer(unsigned int format,int size);
int _stdcall DestroyBuffer(SNDBUF hBuff); 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 SetFormat(SNDBUF hBuff, unsigned int format);
int _stdcall GetFormat(SNDBUF hBuff);
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
int _stdcall SetBufferPos(SNDBUF hBuff, int offset); 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 SetVolume(SNDBUF hBuff, int left, int right);
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
int _stdcall SetPan(SNDBUF hBuff, int pan); int _stdcall SetPan(SNDBUF hBuff, int pan);
int _stdcall GetPan(SNDBUF hBuff);
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); int _stdcall GetMasterVol(int* vol);
int _stdcall SetMasterVol(int vol);
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;
unsigned int _stdcall test_wav(WAVEHEADER *hdr); unsigned int _stdcall test_wav(WAVEHEADER *hdr);

View File

@ -128,12 +128,13 @@ endp
section '.data' align 16 data readable writable section '.data' align 16 data readable writable
szInfinity db 'INFINITY',0
szSound db 'SOUND',0
public hSound public hSound
public hrdwSound public hrdwSound
align 4
hSound dd ? hSound dd ?
hrdwSound dd ? hrdwSound dd ?
szInfinity db 'INFINITY',0
szSound db 'SOUND',0

View File

@ -8,7 +8,7 @@ section '.text' align 16 code readable executable
extrn hSound extrn hSound
public _SetBuffer@16 public _SetBuffer@16
public _PlayBuffer@4 public _PlayBuffer@8
align 4 align 4
proc _SetBuffer@16 stdcall,str:dword, src:dword, offs:dword, size:dword 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 endp
align 4 align 4
proc _PlayBuffer@4 stdcall, str:dword proc _PlayBuffer@8 stdcall, str:dword,flags:dword
locals locals
handle dd ? handle dd ?
io_code dd ? io_code dd ?

View File

@ -16,15 +16,19 @@ SRV_GETVERSION equ 0
SND_CREATE_BUFF equ 1 SND_CREATE_BUFF equ 1
SND_DESTROY_BUFF equ 2 SND_DESTROY_BUFF equ 2
SND_SETFORMAT equ 3 SND_SETFORMAT equ 3
SND_RESET equ 4 SND_GETFORMAT equ 4
SND_SETPOS equ 5 SND_RESET equ 5
SND_SETBUFF equ 6 SND_SETPOS equ 6
SND_SETVOLUME equ 7 SND_GETPOS equ 7
SND_GETVOLUME equ 8 SND_SETBUFF equ 8
SND_OUT equ 9 SND_OUT equ 9
SND_PLAY equ 10 SND_PLAY equ 10
SND_STOP equ 11 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_SET_BUFF equ 4
DEV_NOTIFY equ 5 DEV_NOTIFY equ 5

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -118,7 +118,7 @@ typedef enum
#define MAXPLAYERS 4 #define MAXPLAYERS 4
// State updates, number of tics / second. // State updates, number of tics / second.
#define TICRATE 35 #define TICRATE 30
// The current state of the game: whether we are // The current state of the game: whether we are
// playing, gazing at the intermission screen, // playing, gazing at the intermission screen,

View File

@ -49,6 +49,7 @@ rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
#include "doomdef.h" #include "doomdef.h"
#include "kolibri.h" #include "kolibri.h"
#include "sound.h"
// The number of internal mixing channels, // The number of internal mixing channels,
// the samples calculated for each mixing step, // 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. // Needed for calling the actual sound output.
#define SAMPLECOUNT 8192 #define SAMPLECOUNT 1024
#define NUM_CHANNELS 16 #define NUM_CHANNELS 16
// It is 2 for 16bit, and 2 for two channels. // It is 2 for 16bit, and 2 for two channels.
#define BUFMUL 4 //#define BUFMUL 4
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) //#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
#define SAMPLERATE 11025 // Hz #define SAMPLERATE 11025 // Hz
#define SAMPLESIZE 2 // 16bit #define SAMPLESIZE 2 // 16bit
@ -76,8 +77,7 @@ int audio_fd;
// Basically, samples from all active internal channels // Basically, samples from all active internal channels
// are modifed and added, and stored in the buffer // are modifed and added, and stored in the buffer
// that is submitted to the audio device. // that is submitted to the audio device.
signed short mixbuffer[MIXBUFFERSIZE]; signed short *mixbuffer;
// The channel step amount... // The channel step amount...
unsigned int channelstep[NUM_CHANNELS]; unsigned int channelstep[NUM_CHANNELS];
@ -291,10 +291,17 @@ int addsfx(int sfxid, int volume, int step, int seperation)
// Sanity check, clamp volume. // Sanity check, clamp volume.
if (rightvol < 0 || rightvol > 127) 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) 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 // Get the proper lookup table piece
// for this volume level??? // for this volume level???
@ -426,8 +433,9 @@ int I_SoundIsPlaying(int handle)
// This function currently supports only 16bit. // This function currently supports only 16bit.
// //
extern DWORD hMixBuff[4]; extern SNDBUF hMixBuff;
extern int mix_ptr; extern unsigned int mix_offset;
extern int mix_size;
void I_UpdateSound( void ) void I_UpdateSound( void )
{ {
@ -441,7 +449,7 @@ void I_UpdateSound( void )
// Pointers in global mixbuffer, left, right, end. // Pointers in global mixbuffer, left, right, end.
signed short* leftout; signed short* leftout;
signed short* rightout; signed short* rightout;
signed short* leftend; // signed short* leftend;
// Step in mixbuffer, left and right, thus two. // Step in mixbuffer, left and right, thus two.
int step; int step;
@ -449,7 +457,7 @@ void I_UpdateSound( void )
int chan; int chan;
int i; int i;
int flags; int flags;
flags = 0; int size = 0;
// Left and right channel // Left and right channel
// are in global mixbuffer, alternating. // are in global mixbuffer, alternating.
@ -459,12 +467,12 @@ void I_UpdateSound( void )
// Determine end, for left channel only // Determine end, for left channel only
// (right channel is implicit). // (right channel is implicit).
leftend = mixbuffer + SAMPLECOUNT*step; // leftend = mixbuffer + SAMPLECOUNT*step;
// Mix sounds into the mixing buffer. // Mix sounds into the mixing buffer.
// Loop over step*SAMPLECOUNT, // Loop over step*SAMPLECOUNT,
// that is 512 values for two channels. // 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. // Reset left/right value.
dl = 0; dl = 0;
@ -473,12 +481,14 @@ void I_UpdateSound( void )
// Love thy L2 chache - made this a loop. // Love thy L2 chache - made this a loop.
// Now more channels could be set at compile time // Now more channels could be set at compile time
// as well. Thus loop those channels. // as well. Thus loop those channels.
// flags=0;
for ( chan = 0; chan < NUM_CHANNELS; chan++ ) for ( chan = 0; chan < NUM_CHANNELS; chan++ )
{ {
// Check channel, if active. // Check channel, if active.
if (channels[ chan ]) if (channels[ chan ])
{ {
flags=1; // flags=1;
// Get the raw data from the channel. // Get the raw data from the channel.
sample = *channels[ chan ]; sample = *channels[ chan ];
@ -525,11 +535,22 @@ void I_UpdateSound( void )
// Increment current pointers in mixbuffer. // Increment current pointers in mixbuffer.
leftout += step; leftout += step;
rightout += step; rightout += step;
// if (flags)
// size+=4;
} }
if(flags)
{ WaveOut(hMixBuff[mix_ptr],(char*)&mixbuffer[0],32768); SetBuffer(hMixBuff,mixbuffer,mix_offset,mix_size);
mix_ptr= (mix_ptr+1)&3;
};
// 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; handle = vol = sep = pitch = 0;
} }
extern volatile int sound_state;
void I_ShutdownSound(void) void I_ShutdownSound(void)
{ {
// Wait till all pending sounds are finished. sound_state=0;
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;
}
return; return;
} }
@ -603,8 +612,8 @@ void I_InitSound()
printf( " pre-cached all sound data\n"); printf( " pre-cached all sound data\n");
// Now initialize mixbuffer with zero. // Now initialize mixbuffer with zero.
for ( i = 0; i< MIXBUFFERSIZE; i++ ) // for ( i = 0; i< MIXBUFFERSIZE; i++ )
mixbuffer[i] = 0; // mixbuffer[i] = 0;
// Finished initialization. // Finished initialization.
printf("I_InitSound: sound module ready\n"); printf("I_InitSound: sound module ready\n");

View File

@ -91,8 +91,6 @@ int I_GetTime (void)
return (tm*TICRATE)/100; return (tm*TICRATE)/100;
} }
// //
// I_Init // I_Init
// //
@ -109,10 +107,10 @@ void I_Quit (void)
{ {
// __libclog_printf("Calling I_Quit from %x\n",__builtin_return_address(0)); // __libclog_printf("Calling I_Quit from %x\n",__builtin_return_address(0));
D_QuitNetGame (); D_QuitNetGame ();
// I_ShutdownSound(); I_ShutdownSound();
// I_ShutdownMusic(); // I_ShutdownMusic();
M_SaveDefaults (); M_SaveDefaults ();
I_ShutdownGraphics(); // I_ShutdownGraphics();
exit(0); exit(0);
} }
@ -144,6 +142,7 @@ byte* I_AllocLow(int length)
// I_Error // I_Error
// //
extern boolean demorecording; extern boolean demorecording;
extern volatile int sound_state;
void I_Error (char *error, ...) void I_Error (char *error, ...)
{ {
@ -162,6 +161,7 @@ void I_Error (char *error, ...)
D_QuitNetGame (); D_QuitNetGame ();
I_ShutdownGraphics(); I_ShutdownGraphics();
sound_state=0;
// getch(); // getch();
exit(-1); exit(-1);
} }

View File

@ -66,20 +66,11 @@ void _stdcall InitHeap(int heap_size);
void* _stdcall UserAlloc(int size); void* _stdcall UserAlloc(int size);
int _stdcall UserFree(void* p); 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); 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 _stdcall debug_out_hex(DWORD val);
void debug_out_str(char* str); void debug_out_str(char* str);
@ -99,6 +90,8 @@ int wait_for_event(int time);
int wait_for_event_infinite(); int wait_for_event_infinite();
void BeginDraw(void); void BeginDraw(void);
void EndDraw(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, void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style,
int captioncolor,int windowtype,int bordercolor); int captioncolor,int windowtype,int bordercolor);
void _stdcall debug_out(int ch); void _stdcall debug_out(int ch);

View File

@ -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_

View File

@ -47,6 +47,7 @@ rcsid[] = "$Id: s_sound.c,v 1.6 1997/02/03 22:45:12 b1 Exp $";
#include "kolibri.h" #include "kolibri.h"
#include "sound.h"
void WriteDebug(char *); void WriteDebug(char *);
@ -165,23 +166,19 @@ void S_StopChannel(int cnum);
// allocates channel buffer, sets S_sfx lookup. // 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 void S_Init
( int sfxVolume, ( int sfxVolume,
int musicVolume ) int musicVolume )
{ {
int i; int i;
char *thread_stack;
printf("S_Init: default sfx volume %d\n", sfxVolume); int ver;
InitSound();
hMixBuff[0]= CreateBuffer(15);
hMixBuff[1]= CreateBuffer(15);
hMixBuff[2]= CreateBuffer(15);
hMixBuff[3]= CreateBuffer(15);
numChannels = NUM_CHANNELS; numChannels = NUM_CHANNELS;
@ -208,8 +205,120 @@ void S_Init
// Note that sounds have not been cached (yet). // Note that sounds have not been cached (yet).
for (i=1 ; i<NUMSFX ; i++) for (i=1 ; i<NUMSFX ; i++)
S_sfx[i].lumpnum = S_sfx[i].usefulness = -1; S_sfx[i].lumpnum = S_sfx[i].usefulness = -1;
/********
if((ver = InitSound())< SOUND_VERSION )
{
printf("Sound service version mismatch\n\r");
printf("Installed version: %d, required version %d\n\r",
ver, SOUND_VERSION);
};
hMixBuff = CreateBuffer(PCM_2_16_11,0);
*********/
thread_stack = UserAlloc(4096);
thread_stack+=4092;
sound_state=1;
CreateThread(sound_proc, thread_stack);
} }
typedef struct
{
unsigned int code;
unsigned int sender;
unsigned int stream;
unsigned int offset;
unsigned int size;
unsigned int unused;
}SND_EVENT;
unsigned int mix_offset;
int mix_size;
extern signed short *mixbuffer;
void sound_proc(void)
{
int ver;
SND_EVENT evnt;
int i;
if((ver = InitSound())< SOUND_VERSION )
{
printf("Sound service version mismatch\n\r");
printf("Installed version: %d, required version %d\n\r",
ver, SOUND_VERSION);
};
hMixBuff=CreateBuffer(PCM_2_16_11|PCM_RING,0);
if(!hMixBuff)
{
printf("sound not available\n\r");
_asm
{
mov eax, -1
int 0x40
};
};
mix_size=GetBufferSize(hMixBuff)/2;
printf("mixer size %d\n\r", mix_size);
mixbuffer = malloc(mix_size);
PlayBuffer(hMixBuff, 0);
while(sound_state)
{
GetNotify(&evnt);
if(evnt.code != 0xFF000001)
{
printf("invalid code %d\n\r", evnt.code);
continue;
}
if(evnt.stream != hMixBuff)
{
printf("invalid stream %d hMixBuff= %d\n\r", evnt.stream, hMixBuff);
continue;
};
mix_offset= evnt.offset;
I_UpdateSound();
};
//flush sound buffers
for(i=0; i<32; i++)
{
GetNotify(&evnt);
if(evnt.code != 0xFF000001)
{
printf("invalid code %d\n\r", evnt.code);
continue;
}
if(evnt.stream != hMixBuff)
{
printf("invalid stream %d hMixBuff= %d\n\r", evnt.stream, hMixBuff);
continue;
};
mix_offset= evnt.offset;
I_UpdateSound();
};
_asm
{
mov eax, -1
int 0x40
};
};
// //
// Per level startup code. // Per level startup code.
// Kills playing sounds at start of level, // Kills playing sounds at start of level,