/programs/games/doom/trunk/h/doomdef.h |
---|
118,7 → 118,7 |
#define MAXPLAYERS 4 |
// State updates, number of tics / second. |
#define TICRATE 30 |
#define TICRATE 35 |
// The current state of the game: whether we are |
// playing, gazing at the intermission screen, |
/programs/games/doom/trunk/i_sound.c |
---|
49,7 → 49,6 |
#include "doomdef.h" |
#include "kolibri.h" |
#include "sound.h" |
// The number of internal mixing channels, |
// the samples calculated for each mixing step, |
58,11 → 57,11 |
// Needed for calling the actual sound output. |
#define SAMPLECOUNT 1024 |
#define SAMPLECOUNT 8192 |
#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 |
77,8 → 76,9 |
// 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; |
signed short mixbuffer[MIXBUFFERSIZE]; |
// The channel step amount... |
unsigned int channelstep[NUM_CHANNELS]; |
// ... and a 0.16 bit remainder of last step. |
291,17 → 291,10 |
// Sanity check, clamp volume. |
if (rightvol < 0 || rightvol > 127) |
{ |
printf("rightvol out of bounds\n\r"); |
rightvol = 0; |
I_Error("rightvol out of bounds"); |
} |
if (leftvol < 0 || leftvol > 127) |
{ |
printf("leftvol out of bounds\n\r"); |
leftvol=0; |
} |
I_Error("leftvol out of bounds"); |
// Get the proper lookup table piece |
// for this volume level??? |
433,9 → 426,8 |
// This function currently supports only 16bit. |
// |
extern SNDBUF hMixBuff; |
extern unsigned int mix_offset; |
extern int mix_size; |
extern DWORD hMixBuff[4]; |
extern int mix_ptr; |
void I_UpdateSound( void ) |
{ |
449,7 → 441,7 |
// 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; |
457,7 → 449,7 |
int chan; |
int i; |
int flags; |
int size = 0; |
flags = 0; |
// Left and right channel |
// are in global mixbuffer, alternating. |
467,12 → 459,12 |
// 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 < mix_size/4; i++) |
for (i=0; i < 8192; i++) |
{ |
// Reset left/right value. |
dl = 0; |
481,14 → 473,12 |
// 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 ]; |
535,22 → 525,11 |
// Increment current pointers in mixbuffer. |
leftout += step; |
rightout += step; |
// if (flags) |
// size+=4; |
} |
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); |
// }; |
if(flags) |
{ WaveOut(hMixBuff[mix_ptr],(char*)&mixbuffer[0],32768); |
mix_ptr= (mix_ptr+1)&3; |
}; |
} |
580,11 → 559,23 |
handle = vol = sep = pitch = 0; |
} |
extern volatile int sound_state; |
void I_ShutdownSound(void) |
{ |
sound_state=0; |
// 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; |
} |
return; |
} |
612,8 → 603,8 |
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"); |
/programs/games/doom/trunk/i_system.c |
---|
91,6 → 91,8 |
return (tm*TICRATE)/100; |
} |
// |
// I_Init |
// |
107,10 → 109,10 |
{ |
// __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); |
} |
142,7 → 144,6 |
// I_Error |
// |
extern boolean demorecording; |
extern volatile int sound_state; |
void I_Error (char *error, ...) |
{ |
161,7 → 162,6 |
D_QuitNetGame (); |
I_ShutdownGraphics(); |
sound_state=0; |
// getch(); |
exit(-1); |
} |
/programs/games/doom/trunk/s_sound.c |
---|
47,7 → 47,6 |
#include "kolibri.h" |
#include "sound.h" |
void WriteDebug(char *); |
166,20 → 165,24 |
// 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. |
205,120 → 208,8 |
// Note that sounds have not been cached (yet). |
for (i=1 ; i<NUMSFX ; i++) |
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. |
// Kills playing sounds at start of level, |
/programs/games/doom/trunk/kolibc/include/sound.h |
---|
File deleted |
/programs/games/doom/trunk/kolibc/include/kolibri.h |
---|
66,11 → 66,20 |
void* _stdcall UserAlloc(int size); |
int _stdcall UserFree(void* p); |
void _stdcall GetNotify(void *event); |
void _stdcall GetNotify(DWORD *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); |
90,8 → 99,6 |
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); |