[Scummvm-cvs-logs] SF.net SVN: scummvm:[41781] scummvm/trunk/engines/gob/sound
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Mon Jun 22 22:27:49 CEST 2009
Revision: 41781
http://scummvm.svn.sourceforge.net/scummvm/?rev=41781&view=rev
Author: drmccoy
Date: 2009-06-22 20:27:47 +0000 (Mon, 22 Jun 2009)
Log Message:
-----------
Added stream-reading loading wrappers to MDYPlayer and added a workaround to fix TBR reading for the moment
Modified Paths:
--------------
scummvm/trunk/engines/gob/sound/adlib.cpp
scummvm/trunk/engines/gob/sound/adlib.h
scummvm/trunk/engines/gob/sound/sound.cpp
Modified: scummvm/trunk/engines/gob/sound/adlib.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/adlib.cpp 2009-06-22 20:18:53 UTC (rev 41780)
+++ scummvm/trunk/engines/gob/sound/adlib.cpp 2009-06-22 20:27:47 UTC (rev 41781)
@@ -498,18 +498,13 @@
_timbresSize = 0;
}
-bool MDYPlayer::loadMDY(const char *fileName) {
- Common::File song;
- byte mdyHeader[70];
+bool MDYPlayer::loadMDY(Common::SeekableReadStream &stream) {
+ unloadMDY();
- unload();
- song.open(fileName);
- if (!song.isOpen())
- return false;
-
_freeData = true;
- song.read(mdyHeader, 70);
+ byte mdyHeader[70];
+ stream.read(mdyHeader, 70);
_tickBeat = mdyHeader[36];
_beatMeasure = mdyHeader[37];
@@ -527,8 +522,7 @@
_pitchBendRangeStep = 300;
_data = new byte[_dataSize];
- song.read(_data, _dataSize);
- song.close();
+ stream.read(_data, _dataSize);
reset();
_playPos = _data;
@@ -536,28 +530,63 @@
return true;
}
+bool MDYPlayer::loadMDY(const char *fileName) {
+ Common::File song;
+
+ song.open(fileName);
+ if (!song.isOpen())
+ return false;
+
+ bool loaded = loadMDY(song);
+
+ song.close();
+
+ return loaded;
+}
+
+bool MDYPlayer::loadTBR(Common::SeekableReadStream &stream) {
+ unloadTBR();
+
+ _timbresSize = stream.size();
+
+ // FIXME: _timbresSize is smaller than setVoice() expects!
+ uint32 rSize = MAX<uint32>(_timbresSize, 810);
+
+ _timbres = new byte[rSize];
+ memset(_timbres, 0, rSize);
+
+ stream.read(_timbres, _timbresSize);
+
+ reset();
+ setVoices();
+
+ return true;
+}
+
bool MDYPlayer::loadTBR(const char *fileName) {
Common::File timbres;
- unload();
timbres.open(fileName);
if (!timbres.isOpen())
return false;
- _timbresSize = timbres.size();
- _timbres = new byte[_timbresSize];
- timbres.read(_timbres, _timbresSize);
+ bool loaded = loadTBR(timbres);
+
timbres.close();
- reset();
- setVoices();
+ return loaded;
+}
- return true;
+void MDYPlayer::unload() {
+ unloadTBR();
+ unloadMDY();
}
-void MDYPlayer::unload() {
+void MDYPlayer::unloadMDY() {
AdLib::unload();
+}
+void MDYPlayer::unloadTBR() {
delete[] _timbres;
_timbres = 0;
@@ -636,7 +665,7 @@
setVoice(channel, timbre, false);
break;
case 0xE0:
- warning("Pitch bend not yet implemented\n");
+ warning("Pitch bend not yet implemented");
note = *(_playPos)++;
note += (unsigned)(*(_playPos++)) << 7;
Modified: scummvm/trunk/engines/gob/sound/adlib.h
===================================================================
--- scummvm/trunk/engines/gob/sound/adlib.h 2009-06-22 20:18:53 UTC (rev 41780)
+++ scummvm/trunk/engines/gob/sound/adlib.h 2009-06-22 20:27:47 UTC (rev 41781)
@@ -142,7 +142,9 @@
~MDYPlayer();
bool loadMDY(const char *fileName);
+ bool loadMDY(Common::SeekableReadStream &stream);
bool loadTBR(const char *fileName);
+ bool loadTBR(Common::SeekableReadStream &stream);
void unload();
@@ -162,6 +164,9 @@
void setVoices();
void setVoice(byte voice, byte instr, bool set);
+ void unloadTBR();
+ void unloadMDY();
+
private:
void init();
};
Modified: scummvm/trunk/engines/gob/sound/sound.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/sound.cpp 2009-06-22 20:18:53 UTC (rev 41780)
+++ scummvm/trunk/engines/gob/sound/sound.cpp 2009-06-22 20:27:47 UTC (rev 41781)
@@ -279,7 +279,18 @@
debugC(1, kDebugSound, "Adlib: Loading MDY data (\"%s\")", fileName);
- return _mdyPlayer->loadMDY(fileName);
+ if (!_vm->_dataIO->existData(fileName)) {
+ warning("Can't open MDY file \"%s\"", fileName);
+ return false;
+ }
+
+ DataStream *stream = _vm->_dataIO->getDataStream(fileName);
+
+ bool loaded = _mdyPlayer->loadMDY(*stream);
+
+ delete stream;
+
+ return loaded;
}
bool Sound::adlibLoadTBR(const char *fileName) {
@@ -289,9 +300,20 @@
if (!_mdyPlayer)
_mdyPlayer = new MDYPlayer(*_vm->_mixer);
+ if (!_vm->_dataIO->existData(fileName)) {
+ warning("Can't open TBR file \"%s\"", fileName);
+ return false;
+ }
+
debugC(1, kDebugSound, "Adlib: Loading MDY instruments (\"%s\")", fileName);
- return _mdyPlayer->loadTBR(fileName);
+ DataStream *stream = _vm->_dataIO->getDataStream(fileName);
+
+ bool loaded = _mdyPlayer->loadTBR(*stream);
+
+ delete stream;
+
+ return loaded;
}
void Sound::adlibPlayTrack(const char *trackname) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list