diff options
author | Vladimir Menshakov | 2011-06-13 20:19:27 +0400 |
---|---|---|
committer | Alyssa Milburn | 2011-06-15 17:34:46 +0200 |
commit | 74dfc349373e04d4243f3449c3f4939f8027c54f (patch) | |
tree | d2f5439e5dd5e632396854e9142f5354c900546e /engines/dreamweb/dreamweb.cpp | |
parent | 5a8b1dbfff587fe0eb689d81eed60fe879fb8f36 (diff) | |
download | scummvm-rg350-74dfc349373e04d4243f3449c3f4939f8027c54f.tar.gz scummvm-rg350-74dfc349373e04d4243f3449c3f4939f8027c54f.tar.bz2 scummvm-rg350-74dfc349373e04d4243f3449c3f4939f8027c54f.zip |
DREAMWEB: added sounds loading
Diffstat (limited to 'engines/dreamweb/dreamweb.cpp')
-rw-r--r-- | engines/dreamweb/dreamweb.cpp | 32 |
1 files changed, 29 insertions, 3 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(); } |