aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
authorVladimir Menshakov2011-06-13 20:19:27 +0400
committerAlyssa Milburn2011-06-15 17:34:46 +0200
commit74dfc349373e04d4243f3449c3f4939f8027c54f (patch)
treed2f5439e5dd5e632396854e9142f5354c900546e /engines/dreamweb
parent5a8b1dbfff587fe0eb689d81eed60fe879fb8f36 (diff)
downloadscummvm-rg350-74dfc349373e04d4243f3449c3f4939f8027c54f.tar.gz
scummvm-rg350-74dfc349373e04d4243f3449c3f4939f8027c54f.tar.bz2
scummvm-rg350-74dfc349373e04d4243f3449c3f4939f8027c54f.zip
DREAMWEB: added sounds loading
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/dreamweb.cpp32
-rw-r--r--engines/dreamweb/dreamweb.h14
2 files changed, 42 insertions, 4 deletions
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 0c2f7b4a61..4614637151 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -372,7 +372,7 @@ void DreamWebEngine::cls() {
}
void DreamWebEngine::soundHandler() {
- uint volume = _context.data.byte(dreamgen::kVolume);
+ //uint volume = _context.data.byte(dreamgen::kVolume);
uint ch0 = _context.data.byte(dreamgen::kCh0playing);
if (ch0 == 255)
ch0 = 0;
@@ -397,8 +397,34 @@ void DreamWebEngine::soundHandler() {
}
}
-void DreamWebEngine::loadSounds(uint bank, const Common::String &file) {
- debug(1, "loadSounds(%u, %s)", bank, file.c_str());
+void DreamWebEngine::loadSounds(uint bank, const Common::String &filename) {
+ debug(1, "loadSounds(%u, %s)", bank, filename.c_str());
+ Common::File file;
+ if (!file.open(filename)) {
+ warning("cannot open %s", filename.c_str());
+ return;
+ }
+
+ uint8 header[0x60];
+ file.read(header, sizeof(header));
+ uint tablesize = READ_LE_UINT16(header + 0x32);
+ debug(1, "table size = %u", tablesize);
+
+ SoundData &soundData = _soundData[bank];
+ soundData.samples.resize(tablesize / 6);
+ uint total = 0;
+ for(uint i = 0; i < tablesize / 6; ++i) {
+ uint8 entry[6];
+ Sample &sample = soundData.samples[i];
+ file.read(entry, sizeof(entry));
+ sample.offset = entry[0] * 0x4000 + READ_LE_UINT16(entry + 1);
+ sample.size = READ_LE_UINT16(entry + 3) * 0x800;
+ total += sample.size;
+ debug(1, "offset: %08x, size: %u", sample.offset, sample.size);
+ }
+ soundData.data.resize(total);
+ file.read(soundData.data.begin(), total);
+ file.close();
}
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index 7dabbc80c5..eff955c990 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -119,7 +119,19 @@ private:
uint _speed;
uint _oldMouseState;
- Common::Array<uint8> _samples[2];
+
+ struct Sample {
+ uint offset;
+ uint size;
+ };
+
+ struct SoundData {
+ Common::Array<Sample> samples;
+ Common::Array<uint8> data;
+ };
+
+ SoundData _soundData[2];
+
Audio::SoundHandle _musicHandle, _soundHandle;
uint _channel0, _channel1;