aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2002-08-29 23:45:15 +0000
committerMax Horn2002-08-29 23:45:15 +0000
commit41c2d6fba344f8688b9462371f13727053ccd890 (patch)
tree687cdd692a2aba7ac85214a6066824fc14456d12
parent4b83c17b31eaab340c8eccee2f64cd68e6c6feb8 (diff)
downloadscummvm-rg350-41c2d6fba344f8688b9462371f13727053ccd890.tar.gz
scummvm-rg350-41c2d6fba344f8688b9462371f13727053ccd890.tar.bz2
scummvm-rg350-41c2d6fba344f8688b9462371f13727053ccd890.zip
sound system cleanup
svn-id: r4867
-rw-r--r--Makefile.common6
-rw-r--r--gui/dialog.cpp4
-rw-r--r--gui/gui.cpp1
-rw-r--r--gui/newgui.cpp7
-rw-r--r--scumm/actor.cpp1
-rw-r--r--scumm/costume.cpp1
-rw-r--r--scumm/imuse.cpp1
-rw-r--r--scumm/resource.cpp1
-rw-r--r--scumm/saveload.cpp1
-rw-r--r--scumm/script_v1.cpp11
-rw-r--r--scumm/script_v2.cpp1
-rw-r--r--scumm/scumm.h2
-rw-r--r--scumm/scummvm.cpp6
-rw-r--r--scumm/smush/scumm_renderer.cpp2
-rw-r--r--scumm/sound.cpp (renamed from sound/sound.cpp)374
-rw-r--r--scumm/sound.h7
-rw-r--r--scumm/string.cpp1
-rw-r--r--sound/mixer.cpp1
-rw-r--r--sound/sound.h136
19 files changed, 229 insertions, 335 deletions
diff --git a/Makefile.common b/Makefile.common
index 95eb818a7c..237c853f70 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -19,8 +19,8 @@ SCUMM_OBJS = scumm/actor.o scumm/akos.o scumm/boxes.o scumm/bundle.o \
scumm/costume.o scumm/debug.o scumm/debugrl.o scumm/gfx.o scumm/imuse.o \
scumm/object.o scumm/resource.o scumm/resource_v2.o scumm/resource_v3.o \
scumm/resource_v4.o scumm/saveload.o scumm/script.o \
- scumm/script_v1.o scumm/script_v2.o scumm/scummvm.o scumm/string.o \
- scumm/sys.o scumm/vars.o scumm/verbs.o \
+ scumm/script_v1.o scumm/script_v2.o scumm/scummvm.o scumm/sound.o \
+ scumm/string.o scumm/sys.o scumm/vars.o scumm/verbs.o \
# scumm/insane.o
SIMON_OBJS = simon/debug.o simon/items.o simon/midi.o simon/res.o simon/simon.o \
@@ -40,7 +40,7 @@ SMUSH_OBJS = scumm/smush/blitter.o \
scumm/smush/saud_channel.o \
scumm/smush/scumm_renderer.o
-SOUND_OBJS = sound/fmopl.o sound/mididrv.o sound/mixer.o sound/sound.o
+SOUND_OBJS = sound/fmopl.o sound/mididrv.o sound/mixer.o
OBJS += $(COMMON_OBJS) $(GUI_OBJS) scumm/libscumm.a simon/libsimon.a $(SOUND_OBJS)
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 13651a1a80..3f3d192475 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -24,10 +24,12 @@
#include "newgui.h"
#include "dialog.h"
#include "widget.h"
-#include "scumm.h"
#include "ListWidget.h"
#include "config-file.h"
+
+#include "scumm/sound.h"
#include "sound/mididrv.h"
+#include "scumm/scumm.h"
#include "scumm/imuse.h"
/*
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 8b2515e4b5..78c9011394 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -22,6 +22,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "sound/mididrv.h"
+#include "scumm/sound.h"
#include "scumm/imuse.h"
#include "gui.h"
#include "guimaps.h"
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index a8e0759926..605cc0bb6e 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -19,11 +19,12 @@
*/
#include "stdafx.h"
-#include "scumm.h"
+#include "util.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
#include "newgui.h"
#include "guimaps.h"
-#include "gui/dialog.h"
-#include "util.h"
+#include "dialog.h"
/*
* TODO list
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 1e663805af..5a807b2313 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -26,6 +26,7 @@
#include "akos.h"
#include "costume.h"
#include "resource.h"
+#include "scumm/sound.h"
#include <math.h>
diff --git a/scumm/costume.cpp b/scumm/costume.cpp
index 2ee0a2afc8..2b6b5447de 100644
--- a/scumm/costume.cpp
+++ b/scumm/costume.cpp
@@ -24,6 +24,7 @@
#include "scumm.h"
#include "actor.h"
#include "costume.h"
+#include "scumm/sound.h"
const byte revBitMask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index 21a228e56f..8bbf7a9208 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -25,6 +25,7 @@
#include "sound/mididrv.h"
#include "scumm/imuse.h"
#include "scumm/saveload.h"
+#include "scumm/sound.h"
/*
* Some constants
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index 1a91504396..af803ba169 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -23,6 +23,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "resource.h"
+#include "scumm/sound.h"
#include <stdio.h>
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 839808120a..bd8c76fc65 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -23,6 +23,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "sound/mididrv.h"
+#include "scumm/sound.h"
#include "scumm/imuse.h"
#include "actor.h"
#include "config-file.h"
diff --git a/scumm/script_v1.cpp b/scumm/script_v1.cpp
index 106923aca9..8dfc3c9509 100644
--- a/scumm/script_v1.cpp
+++ b/scumm/script_v1.cpp
@@ -23,6 +23,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "actor.h"
+#include "scumm/sound.h"
void Scumm::setupOpcodes()
{
@@ -2717,15 +2718,9 @@ void Scumm::decodeParseString()
if (_gameId == GID_LOOM256) {
_vars[VAR_MI1_TIMER] = 0;
if (offset == 0 && delay == 0) {
-#ifdef COMPRESSED_SOUND_FILE
- if (_sound->stopMP3CD() == -1)
-#endif
- _system->stop_cdrom();
+ _sound->stopCD();
} else {
-#ifdef COMPRESSED_SOUND_FILE
- if (_sound->playMP3CDTrack(1, 0, offset, delay) == -1)
-#endif
- _system->play_cdrom(1, 0, offset, delay);
+ _sound->playCDTrack(1, 0, offset, delay);
}
} else {
warning("parseString: 8");
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index 9e2b8c52ca..b8242be326 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -28,6 +28,7 @@
#include "smush/scumm_renderer.h"
#include "sound/mididrv.h"
+#include "scumm/sound.h"
#include "scumm/imuse.h"
void Scumm::setupOpcodes2()
diff --git a/scumm/scumm.h b/scumm/scumm.h
index b4c01e06ff..ecb3e1f468 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -26,7 +26,6 @@
#include "engine.h"
#include "bundle.h"
#include "timer.h"
-#include "sound.h"
#define SCUMMVM_VERSION "0.2.2 CVS"
#define SCUMMVM_CVS "2002-08-21"
@@ -40,6 +39,7 @@ class NewGui;
class Scumm;
class IMuse;
class Actor;
+class Sound;
struct ScummDebugger;
struct Serializer;
struct FindObjectInRoom;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index b41bb43b65..7352a7ae79 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -24,6 +24,7 @@
#include "scumm.h"
#include "sound/mixer.h"
#include "sound/mididrv.h"
+#include "scumm/sound.h"
#include "scumm/imuse.h"
#include "actor.h"
#include "debug.h"
@@ -1383,10 +1384,7 @@ void Scumm::waitForTimer(int msec_delay) {
break;
}
}
-#ifdef COMPRESSED_SOUND_FILE
- if (_sound->updateMP3CD() == -1)
-#endif
- _system->update_cdrom(); /* Loop CD Audio if needed */
+ _sound->updateCD(); // Loop CD Audio if needed
if (_system->get_msecs() >= start_time + msec_delay)
break;
_system->delay_msecs(10);
diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp
index 89f82fa283..96fab15586 100644
--- a/scumm/smush/scumm_renderer.cpp
+++ b/scumm/smush/scumm_renderer.cpp
@@ -24,6 +24,8 @@
#include "scumm_renderer.h"
#include "channel.h"
#include "mixer.h"
+#include "sound/mixer.h"
+#include "scumm/sound.h"
class scumm_mixer : public Mixer {
private:
diff --git a/sound/sound.cpp b/scumm/sound.cpp
index 88f16f442f..9b2e49b03b 100644
--- a/sound/sound.cpp
+++ b/scumm/sound.cpp
@@ -22,6 +22,7 @@
#include "stdafx.h"
#include "scumm/scumm.h"
+#include "sound.h"
#include "sound/mididrv.h"
#include "scumm/imuse.h"
#include "scumm/actor.h"
@@ -172,178 +173,166 @@ void Sound::playSound(int sound) {
byte *ptr;
ptr = _scumm->getResourceAddress(rtSound, sound);
- if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
- ptr += 8;
- _scumm->_vars[_scumm->VAR_MI1_TIMER] = 0;
-#ifdef COMPRESSED_SOUND_FILE
- if ((playMP3CDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
- (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0)) == -1)
-#endif
- _scumm->_system->play_cdrom(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
- (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
-
- _scumm->current_cd_sound = sound;
- return;
- }
- // Support for SFX in Monkey Island 1, Mac version
- // This is rather hackish right now, but works OK. SFX are not sounding
- // 100% correct, though, not sure right now what is causing this.
- else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) {
-
- // Read info from the header
- int size = READ_UINT32_UNALIGNED(ptr+0x60);
- int rate = READ_UINT32_UNALIGNED(ptr+0x64) >> 16;
-
- // Skip over the header (fixed size)
- ptr += 0x72;
-
- // Allocate a sound buffer, copy the data into it, and play
- char *sound = (char*)malloc(size);
- memcpy(sound, ptr, size);
- _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
- return;
- }
- // Support for Putt-Putt sounds - very hackish, too 8-)
- else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('DIGI')) {
- // TODO - discover what data the first chunk, HSHD, contains
- // it might be useful here.
- ptr += 8 + READ_BE_UINT32_UNALIGNED(ptr+12);
- if (READ_UINT32_UNALIGNED(ptr) != MKID('SDAT'))
- return; // abort
-
- int size = READ_BE_UINT32_UNALIGNED(ptr+4);
- int rate = 8000; // FIXME - what value here ?!? this is just a guess for now
-
- // Allocate a sound buffer, copy the data into it, and play
- char *sound = (char*)malloc(size);
- memcpy(sound, ptr + 8, size);
- _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
- return;
- }
- else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) {
- int size, rate;
- char * sound = read_creative_voc_file(ptr, size, rate);
- if(sound != NULL) {
+ if (ptr) {
+ if (READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
+ ptr += 8;
+ _scumm->_vars[_scumm->VAR_MI1_TIMER] = 0;
+ playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
+ (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
+
+ _scumm->current_cd_sound = sound;
+ return;
+ }
+ // Support for SFX in Monkey Island 1, Mac version
+ // This is rather hackish right now, but works OK. SFX are not sounding
+ // 100% correct, though, not sure right now what is causing this.
+ else if (READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) {
+
+ // Read info from the header
+ int size = READ_UINT32_UNALIGNED(ptr+0x60);
+ int rate = READ_UINT32_UNALIGNED(ptr+0x64) >> 16;
+
+ // Skip over the header (fixed size)
+ ptr += 0x72;
+
+ // Allocate a sound buffer, copy the data into it, and play
+ char *sound = (char*)malloc(size);
+ memcpy(sound, ptr, size);
_scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ return;
}
- return;
- }
- // Support for sampled sound effects in Monkey1 and Monkey2
- else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SBL ')) {
- debug(2, "Using SBL sound effect");
-
- // TODO - Figuring out how the SBL chunk works. Here's an
- // example:
- //
- // 53 42 4c 20 00 00 11 ae |SBL ....|
- // 41 55 68 64 00 00 00 03 |AUhd....|
- // 00 00 80 41 55 64 74 00 |...AUdt.|
- // 00 11 9b 01 96 11 00 a6 |........|
- // 00 7f 7f 7e 7e 7e 7e 7e |...~~~~~|
- // 7e 7f 7f 80 80 7f 7f 7f |~.......|
- // 7f 80 80 7f 7e 7d 7d 7e |....~}}~|
- // 7e 7e 7e 7e 7e 7e 7e 7f |~~~~~~~.|
- // 7f 7f 7f 80 80 80 80 80 |........|
- // 80 81 80 80 7f 7f 80 85 |........|
- // 8b 8b 83 78 72 6d 6f 75 |...xrmou|
- // 7a 78 77 7d 83 84 83 81 |zxw}....|
- //
- // The length of the AUhd chunk always seems to be 3 bytes.
- // Let's skip that for now.
- //
- // The starting offset, length and sample rate is all pure
- // guesswork. The result sounds reasonable to me, but I've
- // never heard the original.
-
- int size = READ_BE_UINT32_UNALIGNED(ptr + 4) - 27;
- int rate = 8000;
-
- // Allocate a sound buffer, copy the data into it, and play
- char *sound = (char*)malloc(size);
- memcpy(sound, ptr + 33, size);
- _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
- return;
- }
-
- if ((_scumm->_features & GF_OLD256) && (ptr != NULL)) {
- char *sound;
- int size = READ_LE_UINT32(ptr);
-
-#if 0
- // FIXME - this is just some debug output for Zak256
- if (size != 30) {
- char name[9];
- memcpy(name, ptr+22, 8);
- name[8] = 0;
- printf("Going to play Zak256 sound '%s':\n", name);
- hexdump(ptr, 0x40);
+ // Support for Putt-Putt sounds - very hackish, too 8-)
+ else if (READ_UINT32_UNALIGNED(ptr) == MKID('DIGI')) {
+ // TODO - discover what data the first chunk, HSHD, contains
+ // it might be useful here.
+ ptr += 8 + READ_BE_UINT32_UNALIGNED(ptr+12);
+ if (READ_UINT32_UNALIGNED(ptr) != MKID('SDAT'))
+ return; // abort
+
+ int size = READ_BE_UINT32_UNALIGNED(ptr+4);
+ int rate = 8000; // FIXME - what value here ?!? 8000 is just a guess
+
+ // Allocate a sound buffer, copy the data into it, and play
+ char *sound = (char*)malloc(size);
+ memcpy(sound, ptr + 8, size);
+ _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ return;
}
- /*
- There seems to be some pattern in the Zak256 sound data. Two typical
- examples are these:
-
- d7 10 00 00 53 4f d1 10 |....SO..|
- 00 00 00 00 04 00 ff 00 |........|
- 64 00 00 00 01 00 64 6f |d.....do|
- 6f 72 6f 70 65 6e 40 a8 |oropen@.|
- 57 14 a1 10 00 00 50 08 |W.....P.|
- 00 00 00 00 00 00 b3 07 |........|
- 00 00 3c 00 00 00 04 80 |..<.....|
- 03 02 0a 01 8c 82 87 81 |........|
-
- 5b 07 00 00 53 4f 55 07 |[...SOU.|
- 00 00 00 00 04 00 ff 00 |........|
- 64 00 00 00 01 00 64 72 |d.....dr|
- 77 6f 70 65 6e 00 53 a8 |wopen.S.|
- 57 14 25 07 00 00 92 03 |W.%.....|
- 00 00 00 00 00 00 88 03 |........|
- 00 00 3c 00 00 00 82 82 |..<.....|
- 83 84 86 88 89 8b 89 89 |........|
-
- As you can see, there are quite some patterns, e.g.
- the 00 00 00 3c - the sound data seems to start at
- offset 54.
- */
-#endif
-
- ptr += 0x16;
- if (size == 30) {
- int result = 0;
- int track = *ptr;
-
- if (track == _scumm->current_cd_sound)
-#ifdef COMPRESSED_SOUND_FILE
- if (pollMP3CD())
- result = 1;
- else
-#endif
- result = _scumm->_system->poll_cdrom();
- if (result == 1) return;
-
-#ifdef COMPRESSED_SOUND_FILE
- if (playMP3CDTrack(track, 1, 0, 0) == -1)
-#endif
- _scumm->_system->play_cdrom(track, 0, 0, 0);
- _scumm->current_cd_sound = track;
+ else if (READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) {
+ int size, rate;
+ char * sound = read_creative_voc_file(ptr, size, rate);
+ if(sound != NULL) {
+ _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ }
return;
}
-
- size -= 0x36;
- sound = (char*)malloc(size);
- for (int x = 0; x < size; x++) {
- int bit = *ptr++;
- if (bit<0x80) sound[x] = 0x7F-bit; else sound[x] = bit;
+ // Support for sampled sound effects in Monkey1 and Monkey2
+ else if (READ_UINT32_UNALIGNED(ptr) == MKID('SBL ')) {
+ debug(2, "Using SBL sound effect");
+
+ // TODO - Figuring out how the SBL chunk works. Here's an
+ // example:
+ //
+ // 53 42 4c 20 00 00 11 ae |SBL ....|
+ // 41 55 68 64 00 00 00 03 |AUhd....|
+ // 00 00 80 41 55 64 74 00 |...AUdt.|
+ // 00 11 9b 01 96 11 00 a6 |........|
+ // 00 7f 7f 7e 7e 7e 7e 7e |...~~~~~|
+ // 7e 7f 7f 80 80 7f 7f 7f |~.......|
+ // 7f 80 80 7f 7e 7d 7d 7e |....~}}~|
+ // 7e 7e 7e 7e 7e 7e 7e 7f |~~~~~~~.|
+ // 7f 7f 7f 80 80 80 80 80 |........|
+ // 80 81 80 80 7f 7f 80 85 |........|
+ // 8b 8b 83 78 72 6d 6f 75 |...xrmou|
+ // 7a 78 77 7d 83 84 83 81 |zxw}....|
+ //
+ // The length of the AUhd chunk always seems to be 3 bytes.
+ // Let's skip that for now.
+ //
+ // The starting offset, length and sample rate is all pure
+ // guesswork. The result sounds reasonable to me, but I've
+ // never heard the original.
+
+ int size = READ_BE_UINT32_UNALIGNED(ptr + 4) - 27;
+ int rate = 8000;
+
+ // Allocate a sound buffer, copy the data into it, and play
+ char *sound = (char*)malloc(size);
+ memcpy(sound, ptr + 33, size);
+ _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ return;
+ } else if (_scumm->_features & GF_OLD256) {
+ char *sound;
+ int size = READ_LE_UINT32(ptr);
+
+ #if 0
+ // FIXME - this is just some debug output for Zak256
+ if (size != 30) {
+ char name[9];
+ memcpy(name, ptr+22, 8);
+ name[8] = 0;
+ printf("Going to play Zak256 sound '%s':\n", name);
+ hexdump(ptr, 0x40);
+ }
+ /*
+ There seems to be some pattern in the Zak256 sound data. Two typical
+ examples are these:
+
+ d7 10 00 00 53 4f d1 10 |....SO..|
+ 00 00 00 00 04 00 ff 00 |........|
+ 64 00 00 00 01 00 64 6f |d.....do|
+ 6f 72 6f 70 65 6e 40 a8 |oropen@.|
+ 57 14 a1 10 00 00 50 08 |W.....P.|
+ 00 00 00 00 00 00 b3 07 |........|
+ 00 00 3c 00 00 00 04 80 |..<.....|
+ 03 02 0a 01 8c 82 87 81 |........|
+
+ 5b 07 00 00 53 4f 55 07 |[...SOU.|
+ 00 00 00 00 04 00 ff 00 |........|
+ 64 00 00 00 01 00 64 72 |d.....dr|
+ 77 6f 70 65 6e 00 53 a8 |wopen.S.|
+ 57 14 25 07 00 00 92 03 |W.%.....|
+ 00 00 00 00 00 00 88 03 |........|
+ 00 00 3c 00 00 00 82 82 |..<.....|
+ 83 84 86 88 89 8b 89 89 |........|
+
+ As you can see, there are quite some patterns, e.g.
+ the 00 00 00 3c - the sound data seems to start at
+ offset 54.
+ */
+ #endif
+
+ ptr += 0x16;
+ if (size == 30) {
+ int result = 0;
+ int track = *ptr;
+
+ if (track == _scumm->current_cd_sound)
+ result = pollCD();
+ if (result == 1) return;
+
+ playCDTrack(track, 1, 0, 0);
+ return;
+ }
+
+ size -= 0x36;
+ sound = (char*)malloc(size);
+ for (int x = 0; x < size; x++) {
+ int bit = *ptr++;
+ if (bit<0x80) sound[x] = 0x7F-bit; else sound[x] = bit;
+ }
+
+ // FIXME: Maybe something in the header signifies looping? Need to
+ // track it down and add a mixer flag or something (see also bug .
+ _scumm->_mixer->playRaw(NULL, sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ return;
}
-
- // FIXME: Something in the header signifies looping. Need to track it down and add a
- // mixer flag or something.
- _scumm->_mixer->playRaw(NULL, sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
- return;
+
+ if (_scumm->_gameId == GID_MONKEY_VGA)
+ return; /* FIXME */
+
}
- if (_scumm->_gameId == GID_MONKEY_VGA)
- return; /* FIXME */
-
IMuse *se = _scumm->_imuse;
if (se) {
_scumm->getResourceAddress(rtSound, sound);
@@ -494,12 +483,7 @@ int Sound::isSoundRunning(int sound) {
int i;
if (sound == _scumm->current_cd_sound)
-#ifdef COMPRESSED_SOUND_FILE
- if (pollMP3CD())
- return 1;
- else
-#endif
- return _scumm->_system->poll_cdrom();
+ return pollCD();
i = _soundQue2Pos;
while (i--) {
@@ -545,10 +529,7 @@ void Sound::stopSound(int a) {
if (a != 0 && a == _scumm->current_cd_sound) {
_scumm->current_cd_sound = 0;
-#ifdef COMPRESSED_SOUND_FILE
- if (stopMP3CD() == -1)
-#endif
- _scumm->_system->stop_cdrom();
+ stopCD();
}
se = _scumm->_imuse;
@@ -566,10 +547,7 @@ void Sound::stopAllSounds()
if (_scumm->current_cd_sound != 0) {
_scumm->current_cd_sound = 0;
-#ifdef COMPRESSED_SOUND_FILE
- if (stopMP3CD() == -1)
-#endif
- _scumm->_system->stop_cdrom();
+ stopCD();
}
if (se) {
@@ -650,6 +628,13 @@ int Sound::startSfxSound(void *file, int file_size) {
int rate, comp;
byte *data;
+ // FIXME: Day of the Tentacle frequently assumes that starting one sound
+ // effect will automatically stop any other that may be playing at that
+ // time. Do any other games need this?
+
+ if (_scumm->_gameId == GID_TENTACLE)
+ stopSfxSound();
+
#ifdef COMPRESSED_SOUND_FILE
if (file_size > 0) {
data = (byte *)calloc(file_size + MAD_BUFFER_GUARD, 1);
@@ -1014,6 +999,39 @@ int Sound::playSfxSound_MP3(void *sound, uint32 size) {
return -1;
}
+void Sound::playCDTrack(int track, int num_loops, int start, int delay)
+{
+#ifdef COMPRESSED_SOUND_FILE
+ if (playMP3CDTrack(track, num_loops, start, delay) == -1)
+#endif
+ _scumm->_system->play_cdrom(track, num_loops, start, delay);
+}
+
+void Sound::stopCD()
+{
+#ifdef COMPRESSED_SOUND_FILE
+ if (stopMP3CD() == -1)
+#endif
+ _scumm->_system->stop_cdrom();
+}
+
+int Sound::pollCD()
+{
+#ifdef COMPRESSED_SOUND_FILE
+ if (pollMP3CD())
+ return 1;
+#endif
+ return _scumm->_system->poll_cdrom();
+}
+
+void Sound::updateCD()
+{
+#ifdef COMPRESSED_SOUND_FILE
+ if (updateMP3CD() == -1)
+#endif
+ _scumm->_system->update_cdrom();
+}
+
#ifdef COMPRESSED_SOUND_FILE
int Sound::getCachedTrack(int track) {
diff --git a/scumm/sound.h b/scumm/sound.h
index 4d2a554d6c..1e650018cd 100644
--- a/scumm/sound.h
+++ b/scumm/sound.h
@@ -122,6 +122,12 @@ public:
int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned);
int playSfxSound_MP3(void *sound, uint32 size);
+ void playCDTrack(int track, int num_loops, int start, int delay);
+ void stopCD();
+ int pollCD();
+ void updateCD();
+
+protected:
#ifdef COMPRESSED_SOUND_FILE
int getCachedTrack(int track);
int playMP3CDTrack(int track, int num_loops, int start, int delay);
@@ -129,7 +135,6 @@ public:
int pollMP3CD();
int updateMP3CD();
#endif
-
};
#endif
diff --git a/scumm/string.cpp b/scumm/string.cpp
index 00f1cdd04d..1c85f6a7c9 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -23,6 +23,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "actor.h"
+#include "scumm/sound.h"
int CharsetRenderer::getStringWidth(int arg, byte *text, int pos)
{
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 21a606448d..2158f949dd 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -22,6 +22,7 @@
#include "stdafx.h"
#include "scumm.h"
+#include "mixer.h"
SoundMixer::SoundMixer() {
_volumeTable = (int16 *)calloc(256 * sizeof(int16), 1);
diff --git a/sound/sound.h b/sound/sound.h
deleted file mode 100644
index 4d2a554d6c..0000000000
--- a/sound/sound.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2002 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- */
-
-#ifndef SOUND_H
-#define SOUND_H
-
-#include "scummsys.h"
-#include "sound/mixer.h"
-
-class Scumm;
-
-class Sound {
-
-private:
-
-enum {
- SOUND_HEADER_SIZE = 26,
- SOUND_HEADER_BIG_SIZE = 26 + 8,
-
-};
-
- int16 _soundQuePos, _soundQue[0x100];
- byte _soundQue2Pos, _soundQue2[10];
- bool _soundsPaused2;
- bool _soundVolumePreset;
-
- int32 _numberBundleMusic;
- int32 _currentSampleBundleMusic;
- int32 _numberSamplesBundleMusic;
- int32 _offsetSampleBundleMusic;
- int32 _offsetBufBundleMusic;
- byte * _musicBundleBufFinal;
- byte * _musicBundleBufOutput;
- bool _pauseBundleMusic;
-
-
- int _talkChannel; /* Mixer channel actor is talking on */
- void *_sfxFile;
- uint32 _talk_sound_a, _talk_sound_b;
- byte _talk_sound_mode;
- bool _mouthSyncMode;
- bool _endOfMouthSync;
- uint16 _mouthSyncTimes[52];
- uint _curSoundPos;
-
- MP3OffsetTable *offset_table; // SO3 MP3 compressed audio
- int num_sound_effects; // SO3 MP3 compressed audio
-#ifdef COMPRESSED_SOUND_FILE
-
- #define CACHE_TRACKS 10
-
- /* used for mp3 CD music */
-
- int _cached_tracks[CACHE_TRACKS];
- struct mad_header _mad_header[CACHE_TRACKS];
- long _mp3_size[CACHE_TRACKS];
- FILE *_mp3_tracks[CACHE_TRACKS];
- int _mp3_index;
- bool _mp3_cd_playing;
-#endif
-
- Scumm * _scumm;
-
-public:
-
-#ifdef COMPRESSED_SOUND_FILE
-
- int _current_cache;
-
-#endif
-
- bool _soundsPaused;
- int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
- byte _sfxMode;
-
- Sound(Scumm *parent);
- ~Sound();
- void addSoundToQueue(int sound);
- void addSoundToQueue2(int sound);
- void processSoundQues();
- void playSound(int sound);
- void processSfxQueues();
- int startTalkSound(uint32 offset, uint32 b, int mode);
- void stopTalkSound();
- bool isMouthSyncOff(uint pos);
- int isSoundRunning(int sound);
- bool isSoundInQueue(int sound);
- void stopSound(int a);
- void stopAllSounds();
- void clearSoundQue();
- void soundKludge(int16 * list);
- void talkSound(uint32 a, uint32 b, int mode);
- void setupSound();
- void pauseSounds(bool pause);
- int startSfxSound(void *file, int file_size);
- void * openSfxFile();
- void stopSfxSound();
- bool isSfxFinished();
- uint32 decode12BitsSample(byte * src, byte ** dst, uint32 size);
- void playBundleMusic(int32 song);
- void pauseBundleMusic(bool state);
- void bundleMusicHandler(Scumm * scumm);
- void stopBundleMusic();
- void playBundleSound(char *sound);
- int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned);
- int playSfxSound_MP3(void *sound, uint32 size);
-
-#ifdef COMPRESSED_SOUND_FILE
- int getCachedTrack(int track);
- int playMP3CDTrack(int track, int num_loops, int start, int delay);
- int stopMP3CD();
- int pollMP3CD();
- int updateMP3CD();
-#endif
-
-};
-
-#endif
-