aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--saga/sndres.cpp55
-rw-r--r--saga/sndres.h17
-rw-r--r--saga/syssound.cpp53
3 files changed, 33 insertions, 92 deletions
diff --git a/saga/sndres.cpp b/saga/sndres.cpp
index 8920053d06..8e24d95b90 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -50,12 +50,10 @@ namespace Saga {
R_SNDRES_MODULE SndModule;
-int SND_Init(void)
-{
+int SND_Init(void) {
int result;
- /* Load sound module resource file contexts
- * \*------------------------------------------------------------- */
+ /* Load sound module resource file contexts */
result = GAME_GetFileContext(&SndModule.sfx_ctxt, R_GAME_SOUNDFILE, 0);
if (result != R_SUCCESS) {
return R_FAILURE;
@@ -67,8 +65,7 @@ int SND_Init(void)
return R_FAILURE;
}
- /* Grab sound resource information for the current game
- * \*------------------------------------------------------------- */
+ /* Grab sound resource information for the current game */
GAME_GetSoundInfo(&SndModule.snd_info);
SndModule.init = 1;
@@ -76,8 +73,7 @@ int SND_Init(void)
return R_SUCCESS;
}
-int SND_PlayVoice(ulong voice_rn)
-{
+int SND_PlayVoice(ulong voice_rn) {
R_SOUNDBUFFER snd_buffer;
int result;
@@ -91,10 +87,7 @@ int SND_PlayVoice(ulong voice_rn)
return R_SUCCESS;
}
-int
-SND_Load(R_RSCFILE_CONTEXT * snd_ctxt, ulong snd_rn, R_SOUNDBUFFER * snd_buf_i)
-{
-
+int SND_Load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_buf_i) {
uchar *snd_res;
size_t snd_res_len;
@@ -108,9 +101,7 @@ SND_Load(R_RSCFILE_CONTEXT * snd_ctxt, ulong snd_rn, R_SOUNDBUFFER * snd_buf_i)
}
switch (SndModule.snd_info.res_type) {
-
case R_GAME_SOUND_PCM:
-
snd_buf_i->s_freq = SndModule.snd_info.freq;
snd_buf_i->s_samplebits = SndModule.snd_info.sample_size;
snd_buf_i->s_stereo = SndModule.snd_info.stereo;
@@ -126,7 +117,6 @@ SND_Load(R_RSCFILE_CONTEXT * snd_ctxt, ulong snd_rn, R_SOUNDBUFFER * snd_buf_i)
break;
case R_GAME_SOUND_VOC:
-
if (LoadVocSound(snd_res, snd_res_len, snd_buf_i) != R_SUCCESS) {
RSC_FreeResource(snd_res);
@@ -138,7 +128,6 @@ SND_Load(R_RSCFILE_CONTEXT * snd_ctxt, ulong snd_rn, R_SOUNDBUFFER * snd_buf_i)
default:
/* Unknown sound type */
-
RSC_FreeResource(snd_res);
return R_FAILURE;
@@ -148,11 +137,7 @@ SND_Load(R_RSCFILE_CONTEXT * snd_ctxt, ulong snd_rn, R_SOUNDBUFFER * snd_buf_i)
return R_SUCCESS;
}
-int
-LoadVocSound(const uchar * snd_res,
- size_t snd_res_len, R_SOUNDBUFFER * snd_buf_i)
-{
-
+int LoadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i) {
R_VOC_HEADER_BLOCK voc_hb;
R_VOC_GENBLOCK voc_gb;
R_VOC_BLOCK1 voc_b1;
@@ -174,7 +159,6 @@ LoadVocSound(const uchar * snd_res,
read_len -= R_VOC_FILE_DESC_LEN;
if (memcmp(voc_hb.ft_desc, R_VOC_FILE_DESC, R_VOC_FILE_DESC_LEN) != 0) {
-
/* Voc file desc string not found */
return R_FAILURE;
}
@@ -184,7 +168,6 @@ LoadVocSound(const uchar * snd_res,
voc_hb.voc_fileid = ys_read_u16_le(read_p, &read_p);
if (read_len < voc_hb.db_offset + R_VOC_GENBLOCK_LEN) {
-
return R_FAILURE;
}
@@ -192,9 +175,7 @@ LoadVocSound(const uchar * snd_res,
read_len = snd_res_len - voc_hb.db_offset;
for (;;) {
-
- /* Read generic block header
- * \*--------------------------------------------------------- */
+ /* Read generic block header */
if (read_len < R_VOC_GENBLOCK_LEN) {
return R_FAILURE;
}
@@ -208,12 +189,9 @@ LoadVocSound(const uchar * snd_res,
read_len -= R_VOC_GENBLOCK_LEN;
- /* Process block
- * \*--------------------------------------------------------- */
+ /* Process block */
switch (voc_gb.block_id) {
-
case 1: /* Sound data block */
-
voc_b1.time_constant = ys_read_u8(read_p, &read_p);
voc_b1.pack_method = ys_read_u8(read_p, &read_p);
read_len -= 2;
@@ -243,7 +221,6 @@ LoadVocSound(const uchar * snd_res,
break;
default:
-
read_p += voc_gb.block_len;
read_len -= voc_gb.block_len;
break;
@@ -253,9 +230,7 @@ LoadVocSound(const uchar * snd_res,
return R_SUCCESS;
}
-int SND_GetVoiceLength(ulong voice_rn)
-{
-
+int SND_GetVoiceLength(ulong voice_rn) {
ulong length;
double ms_f;
@@ -271,16 +246,13 @@ int SND_GetVoiceLength(ulong voice_rn)
}
if (SndModule.snd_info.res_type == R_GAME_SOUND_PCM) {
-
ms_f = (double)length /
(SndModule.snd_info.sample_size / CHAR_BIT) /
(SndModule.snd_info.freq) * 1000.0;
ms_i = (int)ms_f;
} else if (SndModule.snd_info.res_type == R_GAME_SOUND_VOC) {
-
/* Rough hack, fix this to be accurate */
-
ms_f = (double)length / 14705 * 1000.0;
ms_i = (int)ms_f;
} else {
@@ -290,12 +262,8 @@ int SND_GetVoiceLength(ulong voice_rn)
return ms_i;
}
-int
-SND_ITEVOC_Resample(long src_freq,
- long dst_freq,
- uchar * src_buf,
- size_t src_buf_len, uchar ** dst_buf, size_t * dst_buf_len)
-{
+int SND_ITEVOC_Resample(long src_freq, long dst_freq, uchar *src_buf,
+ size_t src_buf_len, uchar **dst_buf, size_t *dst_buf_len) {
uchar *resamp_buf;
size_t resamp_len;
@@ -328,7 +296,6 @@ SND_ITEVOC_Resample(long src_freq,
write_pc = resamp_buf + 2;
for (src_i = 0; src_i < src_buf_len / 2; src_i++) {
-
src_samp_a = *read_pa;
src_samp_b = *read_pb;
diff --git a/saga/sndres.h b/saga/sndres.h
index 961fd19968..866c39b823 100644
--- a/saga/sndres.h
+++ b/saga/sndres.h
@@ -40,52 +40,39 @@ namespace Saga {
#define R_VOC_FILE_DESC "Creative Voice File\x1A"
struct R_VOC_HEADER_BLOCK {
-
char ft_desc[20]; /* BYTE [20] */
uint db_offset; /* WORD */
uint voc_version; /* WORD */
uint voc_fileid; /* WORD */
-
};
#define R_VOC_HEADER_BLOCK_LEN 26
struct R_VOC_GENBLOCK {
-
int block_id; /* BYTE */
ulong block_len; /* BYTE[3] */
-
};
#define R_VOC_GENBLOCK_LEN 4
struct R_VOC_BLOCK1 {
-
int block_id; /* BYTE */
ulong block_len; /* BYTE[3] */
uint time_constant; /* BYTE */
int pack_method; /* BYTE */
-
};
struct R_SNDRES_MODULE {
-
int init;
R_RSCFILE_CONTEXT *sfx_ctxt;
R_RSCFILE_CONTEXT *voice_ctxt;
R_GAME_SOUNDINFO snd_info;
-
};
-int
-SND_Load(R_RSCFILE_CONTEXT * snd_ctxt,
- ulong snd_rn, R_SOUNDBUFFER * snd_buf_i);
-
-int
-LoadVocSound(const uchar * snd_res,
- size_t snd_res_len, R_SOUNDBUFFER * snd_buf_i);
+int SND_Load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_buf_i);
+int LoadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i);
} // End of namespace Saga
diff --git a/saga/syssound.cpp b/saga/syssound.cpp
index ca50536ffa..07d7091130 100644
--- a/saga/syssound.cpp
+++ b/saga/syssound.cpp
@@ -41,13 +41,9 @@ static int SoundInitialized = 0;
static R_RSCFILE_CONTEXT *SoundContext;
static R_RSCFILE_CONTEXT *VoiceContext;
-int SYSSOUND_Init(int enabled)
-{
-
+int SYSSOUND_Init(int enabled) {
int result;
- YS_IGNORE_PARAM(enabled);
-
if (SoundInitialized) {
return R_FAILURE;
}
@@ -64,12 +60,15 @@ int SYSSOUND_Init(int enabled)
return R_FAILURE;
}
+ /* Grab sound resource information for the current game
+ \*-------------------------------------------------------------*/
+ //GAME_GetSoundInfo(&SoundModule.snd_info);
+
SoundInitialized = 1;
return R_SUCCESS;
}
-int SYSSOUND_Shutdown()
-{
+int SYSSOUND_Shutdown() {
if (!SoundInitialized) {
return R_FAILURE;
}
@@ -79,22 +78,22 @@ int SYSSOUND_Shutdown()
return R_SUCCESS;
}
-int SYSSOUND_Play(int sound_rn, int channel)
-{
-
- (void)sound_rn;
- (void)channel;
+int SYSSOUND_Play(int sound_rn, int channel) {
+ int resource_size;
+ char *resource_data;
if (!SoundInitialized) {
return R_FAILURE;
}
+ if (channel > 3) {
+ return R_FAILURE;
+ }
+
return R_SUCCESS;
}
-int SYSSOUND_Pause(int channel)
-{
-
+int SYSSOUND_Pause(int channel) {
(void)channel;
if (!SoundInitialized) {
@@ -104,9 +103,7 @@ int SYSSOUND_Pause(int channel)
return R_SUCCESS;
}
-int SYSSOUND_Resume(int channel)
-{
-
+int SYSSOUND_Resume(int channel) {
(void)channel;
if (!SoundInitialized) {
@@ -116,9 +113,7 @@ int SYSSOUND_Resume(int channel)
return R_SUCCESS;
}
-int SYSSOUND_Stop(int channel)
-{
-
+int SYSSOUND_Stop(int channel) {
(void)channel;
if (!SoundInitialized) {
@@ -128,9 +123,7 @@ int SYSSOUND_Stop(int channel)
return R_SUCCESS;
}
-int SYSSOUND_PlayVoice(R_SOUNDBUFFER * buf)
-{
-
+int SYSSOUND_PlayVoice(R_SOUNDBUFFER *buf) {
(void)buf;
if (!SoundInitialized) {
@@ -140,9 +133,7 @@ int SYSSOUND_PlayVoice(R_SOUNDBUFFER * buf)
return R_SUCCESS;
}
-int SYSSOUND_PauseVoice(void)
-{
-
+int SYSSOUND_PauseVoice(void) {
if (!SoundInitialized) {
return R_FAILURE;
}
@@ -150,9 +141,7 @@ int SYSSOUND_PauseVoice(void)
return R_SUCCESS;
}
-int SYSSOUND_ResumeVoice(void)
-{
-
+int SYSSOUND_ResumeVoice(void) {
if (!SoundInitialized) {
return R_FAILURE;
}
@@ -160,9 +149,7 @@ int SYSSOUND_ResumeVoice(void)
return R_SUCCESS;
}
-int SYSSOUND_StopVoice(void)
-{
-
+int SYSSOUND_StopVoice(void) {
if (!SoundInitialized) {
return R_FAILURE;
}