aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2015-07-23 22:33:56 +0200
committerJohannes Schickel2015-07-23 22:33:56 +0200
commitcf42dc0a358da489ff93d32c18a5103de4dc4385 (patch)
treed9d4d0f6b4cddc7b06002824a6731dd6590705ae
parent33c57c632cc630d1d64266d9ee2bf340d0052049 (diff)
downloadscummvm-rg350-cf42dc0a358da489ff93d32c18a5103de4dc4385.tar.gz
scummvm-rg350-cf42dc0a358da489ff93d32c18a5103de4dc4385.tar.bz2
scummvm-rg350-cf42dc0a358da489ff93d32c18a5103de4dc4385.zip
AGOS: Slight cleanup in Simon1 AdLib output initialization code.
-rw-r--r--engines/agos/drivers/simon1/adlib.cpp22
-rw-r--r--engines/agos/drivers/simon1/adlib.h2
-rw-r--r--engines/agos/midi.cpp25
3 files changed, 33 insertions, 16 deletions
diff --git a/engines/agos/drivers/simon1/adlib.cpp b/engines/agos/drivers/simon1/adlib.cpp
index d331b868fc..7f1370e8bd 100644
--- a/engines/agos/drivers/simon1/adlib.cpp
+++ b/engines/agos/drivers/simon1/adlib.cpp
@@ -24,6 +24,7 @@
#include "common/textconsole.h"
#include "common/util.h"
+#include "common/file.h"
namespace AGOS {
@@ -491,4 +492,25 @@ const MidiDriver_Simon1_AdLib::RhythmMap MidiDriver_Simon1_AdLib::_rhythmMap[39]
{ 13, 125, 100 }
};
+MidiDriver *createMidiDriverSimon1AdLib(const char *instrumentFilename) {
+ // Load instrument data.
+ Common::File ibk;
+
+ if (!ibk.open(instrumentFilename)) {
+ return nullptr;
+ }
+
+ if (ibk.readUint32BE() != 0x49424b1a) {
+ return nullptr;
+ }
+
+ byte *instrumentData = new byte[128 * 16];
+ if (ibk.read(instrumentData, 128 * 16) != 128 * 16) {
+ delete[] instrumentData;
+ return nullptr;
+ }
+
+ return new MidiDriver_Simon1_AdLib(instrumentData);
+}
+
} // End of namespace AGOS
diff --git a/engines/agos/drivers/simon1/adlib.h b/engines/agos/drivers/simon1/adlib.h
index b92c1dde24..6057bf1b16 100644
--- a/engines/agos/drivers/simon1/adlib.h
+++ b/engines/agos/drivers/simon1/adlib.h
@@ -111,6 +111,8 @@ private:
static const RhythmMap _rhythmMap[39];
};
+MidiDriver *createMidiDriverSimon1AdLib(const char *instrumentFilename);
+
} // End of namespace AGOS
#endif
diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp
index 61bab7d847..c5bace0523 100644
--- a/engines/agos/midi.cpp
+++ b/engines/agos/midi.cpp
@@ -238,23 +238,16 @@ int MidiPlayer::open(int gameType, bool isDemo) {
_map_mt32_to_gm = false;
_nativeMT32 = false;
- // Load instrument data.
- Common::File ibk;
-
- if (ibk.open("MT_FM.IBK")) {
- if (ibk.readUint32BE() == 0x49424b1a) {
- byte *instrumentData = new byte[128 * 16];
- if (ibk.read(instrumentData, 128 * 16) == 128 * 16) {
- _driver = new MidiDriver_Simon1_AdLib(instrumentData);
- ret = _driver->open();
- if (ret == 0) {
- _driver->setTimerCallback(this, &onTimer);
- _driver->send(0xB0, 0x67, 0x01);
- return 0;
- }
- }
- }
+ _driver = createMidiDriverSimon1AdLib("MT_FM.IBK");
+ if (_driver && _driver->open() == 0) {
+ _driver->setTimerCallback(this, &onTimer);
+ // Like the original, we enable the rhythm support by default.
+ _driver->send(0xB0, 0x67, 0x01);
+ return 0;
}
+
+ delete _driver;
+ _driver = nullptr;
}
_musicMode = kMusicModeDisabled;